77 "github.com/stretchr/testify/assert"
88
99 "github.com/go-task/task/v3/args"
10- "github.com/go-task/task/v3/internal/omap"
1110 "github.com/go-task/task/v3/taskfile/ast"
1211)
1312
@@ -34,45 +33,55 @@ func TestArgs(t *testing.T) {
3433 {Task : "task-b" },
3534 {Task : "task-c" },
3635 },
37- ExpectedGlobals : & ast.Vars {
38- OrderedMap : omap .FromMapWithOrder (
39- map [string ]ast.Var {
40- "FOO" : {Value : "bar" },
41- "BAR" : {Value : "baz" },
42- "BAZ" : {Value : "foo" },
36+ ExpectedGlobals : ast .NewVars (
37+ & ast.VarElement {
38+ Key : "FOO" ,
39+ Value : ast.Var {
40+ Value : "bar" ,
4341 },
44- []string {"FOO" , "BAR" , "BAZ" },
45- ),
46- },
42+ },
43+ & ast.VarElement {
44+ Key : "BAR" ,
45+ Value : ast.Var {
46+ Value : "baz" ,
47+ },
48+ },
49+ & ast.VarElement {
50+ Key : "BAZ" ,
51+ Value : ast.Var {
52+ Value : "foo" ,
53+ },
54+ },
55+ ),
4756 },
4857 {
4958 Args : []string {"task-a" , "CONTENT=with some spaces" },
5059 ExpectedCalls : []* ast.Call {
5160 {Task : "task-a" },
5261 },
53- ExpectedGlobals : & ast.Vars {
54- OrderedMap : omap .FromMapWithOrder (
55- map [string ]ast.Var {
56- "CONTENT" : {Value : "with some spaces" },
62+ ExpectedGlobals : ast .NewVars (
63+ & ast.VarElement {
64+ Key : "CONTENT" ,
65+ Value : ast.Var {
66+ Value : "with some spaces" ,
5767 },
58- []string {"CONTENT" },
59- ),
60- },
68+ },
69+ ),
6170 },
6271 {
6372 Args : []string {"FOO=bar" , "task-a" , "task-b" },
6473 ExpectedCalls : []* ast.Call {
6574 {Task : "task-a" },
6675 {Task : "task-b" },
6776 },
68- ExpectedGlobals : & ast.Vars {
69- OrderedMap : omap .FromMapWithOrder (
70- map [string ]ast.Var {
71- "FOO" : {Value : "bar" },
77+ ExpectedGlobals : ast .NewVars (
78+ & ast.VarElement {
79+ Key : "FOO" ,
80+ Value : ast.Var {
81+ Value : "bar" ,
7282 },
73- []string {"FOO" },
74- ),
75- },
83+ },
84+ ),
7685 },
7786 {
7887 Args : nil ,
@@ -85,15 +94,20 @@ func TestArgs(t *testing.T) {
8594 {
8695 Args : []string {"FOO=bar" , "BAR=baz" },
8796 ExpectedCalls : []* ast.Call {},
88- ExpectedGlobals : & ast.Vars {
89- OrderedMap : omap . FromMapWithOrder (
90- map [ string ]ast. Var {
91- "FOO" : { Value : "bar" },
92- "BAR" : { Value : "baz" } ,
97+ ExpectedGlobals : ast .NewVars (
98+ & ast. VarElement {
99+ Key : "FOO" ,
100+ Value : ast. Var {
101+ Value : "bar" ,
93102 },
94- []string {"FOO" , "BAR" },
95- ),
96- },
103+ },
104+ & ast.VarElement {
105+ Key : "BAR" ,
106+ Value : ast.Var {
107+ Value : "baz" ,
108+ },
109+ },
110+ ),
97111 },
98112 }
99113
@@ -104,8 +118,8 @@ func TestArgs(t *testing.T) {
104118 calls , globals := args .Parse (test .Args ... )
105119 assert .Equal (t , test .ExpectedCalls , calls )
106120 if test .ExpectedGlobals .Len () > 0 || globals .Len () > 0 {
107- assert .Equal (t , test .ExpectedGlobals . Keys () , globals . Keys () )
108- assert .Equal (t , test .ExpectedGlobals . Values () , globals . Values () )
121+ assert .Equal (t , test .ExpectedGlobals , globals )
122+ assert .Equal (t , test .ExpectedGlobals , globals )
109123 }
110124 })
111125 }
0 commit comments