1// Copyright (c) Microsoft Corporation. All rights reserved. 2// Licensed under the MIT License. See License.txt in the project root for license information. 3 4package model_test 5 6import ( 7 "reflect" 8 "testing" 9 10 "github.com/Azure/azure-sdk-for-go/tools/generator/autorest/model" 11) 12 13func TestNewOption(t *testing.T) { 14 testcase := []struct { 15 input string 16 expected model.Option 17 }{ 18 { 19 input: "specification/compute/resource-manager/readme.md", 20 expected: model.NewArgument("specification/compute/resource-manager/readme.md"), 21 }, 22 { 23 input: "--multiapi", 24 expected: model.NewFlagOption("multiapi"), 25 }, 26 { 27 input: "--tag=package-2020-01-01", 28 expected: model.NewKeyValueOption("tag", "package-2020-01-01"), 29 }, 30 } 31 32 for _, c := range testcase { 33 o, err := model.NewOption(c.input) 34 if err != nil { 35 t.Fatalf("unexpected error: %+v", err) 36 } 37 if !reflect.DeepEqual(o, c.expected) { 38 t.Fatalf("expecting %+v, but got %+v", c.expected, o) 39 } 40 } 41} 42