Skip to content

Commit

Permalink
Add more test server tests (#428)
Browse files Browse the repository at this point in the history
Added missing urlgroup tests.
Added extensible enum codegen and tests.
  • Loading branch information
jhendrixMSFT authored Jun 18, 2020
1 parent 72e3daa commit 6336f43
Show file tree
Hide file tree
Showing 7 changed files with 637 additions and 2 deletions.
1 change: 1 addition & 0 deletions rushScripts/regeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const goMappings = {
'dictionarygroup': 'body-dictionary.json',
//'durationgroup': 'body-duration.json',
'errorsgroup': 'xms-error-responses.json',
'extenumsgroup': 'extensible-enums-swagger.json',
'filegroup': 'body-file.json',
//'formdatagroup': 'body-formdata.json',
'headergroup': 'header.json',
Expand Down
75 changes: 75 additions & 0 deletions test/autorest/extenumsgroup/extenumsgroup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

package extenumsgrouptest

import (
"context"
"generatortests/autorest/generated/extenumsgroup"
"generatortests/helpers"
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/to"
)

func getPetOperations(t *testing.T) extenumsgroup.PetOperations {
client, err := extenumsgroup.NewDefaultClient(nil)
if err != nil {
t.Fatalf("failed to create enum client: %v", err)
}
return client.PetOperations()
}

func TestAddPet(t *testing.T) {
client := getPetOperations(t)
result, err := client.AddPet(context.Background(), &extenumsgroup.PetAddPetOptions{
PetParam: &extenumsgroup.Pet{
Name: to.StringPtr("Retriever"),
},
})
if err != nil {
t.Fatal(err)
}
helpers.DeepEqualOrFatal(t, result.Pet, &extenumsgroup.Pet{
Name: to.StringPtr("Retriever"),
})
}

func TestGetByPetIDExpected(t *testing.T) {
client := getPetOperations(t)
result, err := client.GetByPetID(context.Background(), "tommy")
if err != nil {
t.Fatal(err)
}
helpers.DeepEqualOrFatal(t, result.Pet, &extenumsgroup.Pet{
DaysOfWeek: extenumsgroup.DaysOfWeekExtensibleEnumMonday.ToPtr(),
IntEnum: extenumsgroup.IntEnumOne.ToPtr(),
Name: to.StringPtr("Tommy Tomson"),
})
}

func TestGetByPetIDUnexpected(t *testing.T) {
client := getPetOperations(t)
result, err := client.GetByPetID(context.Background(), "casper")
if err != nil {
t.Fatal(err)
}
helpers.DeepEqualOrFatal(t, result.Pet, &extenumsgroup.Pet{
DaysOfWeek: (*extenumsgroup.DaysOfWeekExtensibleEnum)(to.StringPtr("Weekend")),
IntEnum: extenumsgroup.IntEnumTwo.ToPtr(),
Name: to.StringPtr("Casper Ghosty"),
})
}

func TestGetByPetIDAllowed(t *testing.T) {
client := getPetOperations(t)
result, err := client.GetByPetID(context.Background(), "scooby")
if err != nil {
t.Fatal(err)
}
helpers.DeepEqualOrFatal(t, result.Pet, &extenumsgroup.Pet{
DaysOfWeek: extenumsgroup.DaysOfWeekExtensibleEnumThursday.ToPtr(),
IntEnum: (*extenumsgroup.IntEnum)(to.StringPtr("2.1")),
Name: to.StringPtr("Scooby Scarface"),
})
}
98 changes: 98 additions & 0 deletions test/autorest/generated/extenumsgroup/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions test/autorest/generated/extenumsgroup/enums.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions test/autorest/generated/extenumsgroup/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions test/autorest/generated/extenumsgroup/pet.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6336f43

Please sign in to comment.