@@ -14,43 +14,53 @@ func Test_New(t *testing.T) {
14
14
t .Parallel ()
15
15
16
16
root := cmd .New ()
17
-
18
17
require .Equal (t , "k6deps [flags] [script-file]" , root .Use )
19
18
20
19
dir := t .TempDir ()
21
20
22
21
scriptfile := filepath .Join ("testdata" , "script.js" )
22
+ archive := filepath .Join ("testdata" , "archive.tar" )
23
+
23
24
out := filepath .Clean (filepath .Join (dir , "output" ))
24
25
26
+ root = cmd .New ()
25
27
root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "-o" , out , scriptfile })
26
-
27
28
err := root .Execute ()
28
29
require .NoError (t , err )
29
30
30
31
contents , err := os .ReadFile (out )
31
32
require .NoError (t , err )
32
33
require .Equal (t , `{"k6/x/faker":">v0.3.0","xk6-top":"*"}` + "\n " , string (contents ))
33
34
34
- root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "--format" , "json" , "-o" , out , scriptfile })
35
+ root = cmd .New ()
36
+ root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "-o" , out , archive })
37
+ err = root .Execute ()
38
+ require .NoError (t , err )
35
39
40
+ contents , err = os .ReadFile (out )
41
+ require .NoError (t , err )
42
+ require .Equal (t , `{"k6":">0.54","k6/x/faker":">0.4.0","k6/x/sql":">=1.0.1","k6/x/sql/driver/ramsql":"*"}` + "\n " , string (contents ))
43
+
44
+ root = cmd .New ()
45
+ root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "--format" , "json" , "-o" , out , scriptfile })
36
46
err = root .Execute ()
37
47
require .NoError (t , err )
38
48
39
49
contents , err = os .ReadFile (out )
40
50
require .NoError (t , err )
41
51
require .Equal (t , `{"k6/x/faker":">v0.3.0","xk6-top":"*"}` + "\n " , string (contents ))
42
52
53
+ root = cmd .New ()
43
54
root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "--format" , "text" , "-o" , out , scriptfile })
44
-
45
55
err = root .Execute ()
46
56
require .NoError (t , err )
47
57
48
58
contents , err = os .ReadFile (out )
49
59
require .NoError (t , err )
50
60
require .Equal (t , `k6/x/faker>v0.3.0;xk6-top*` + "\n " , string (contents ))
51
61
62
+ root = cmd .New ()
52
63
root .SetArgs ([]string {"--ingnore-env" , "--ignore-manifest" , "--format" , "js" , "-o" , out , scriptfile })
53
-
54
64
err = root .Execute ()
55
65
require .NoError (t , err )
56
66
0 commit comments