-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing urlgroup tests. Added extensible enum codegen and tests.
- Loading branch information
1 parent
72e3daa
commit 6336f43
Showing
7 changed files
with
637 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.