@@ -29,10 +29,15 @@ func TestCmdLclSetup(t *testing.T) {
2929 })
3030
3131 t .Run ("--cert-style acme" , func (t * testing.T ) {
32- cfg := cmdtest .TestCfg (t , CmdLclSetup , "--method " , "acme" )
32+ cfg := cmdtest .TestCfg (t , CmdLclSetup , "--cert-style " , "acme" )
3333 require .Equal (t , "acme" , cfg .Service .CertStyle )
3434 })
3535
36+ t .Run ("--org-name org" , func (t * testing.T ) {
37+ cfg := cmdtest .TestCfg (t , CmdLclSetup , "--org-name" , "org" )
38+ require .Equal (t , "org" , cfg .Org .Name )
39+ })
40+
3641 // alias
3742
3843 t .Run ("--language python" , func (t * testing.T ) {
@@ -59,7 +64,9 @@ func TestSetup(t *testing.T) {
5964
6065 cfg := cmdtest .Config (ctx )
6166 cfg .API .URL = srv .URL
62- cfg .Test .ACME .URL = "http://anchor.lcl.host:" + srv .RailsPort
67+ if srv .IsProxy () {
68+ cfg .Test .ACME .URL = "http://anchor.lcl.host:" + srv .RailsPort
69+ }
6370 cfg .Trust .MockMode = true
6471 cfg .Trust .NoSudo = true
6572 cfg .Trust .Stores = []string {"mock" }
@@ -73,6 +80,67 @@ func TestSetup(t *testing.T) {
7380
7481 setupGuideURL := cfg .SetupGuideURL ("lcl_setup" , "test-app" )
7582
83+ t .Run ("create-org-existing-service-basics" , func (t * testing.T ) {
84+ if srv .IsProxy () {
85+ t .Skip ("lcl setup existing service unsupported in proxy mode" )
86+ }
87+
88+ ctx , cancel := context .WithCancel (ctx )
89+ defer cancel ()
90+
91+ drv , tm := uitest .TestTUI (ctx , t )
92+
93+ cmd := Setup {
94+ clipboard : new (clipboard.Mock ),
95+ }
96+
97+ errc := make (chan error , 1 )
98+ go func () {
99+ errc <- cmd .UI ().RunTUI (ctx , drv )
100+ errc <- tm .Quit ()
101+ }()
102+
103+ uitest .WaitForGoldenContains (t , drv , errc ,
104+ "? Which organization's lcl.host local development environment do you want to setup?" ,
105+ )
106+ tm .Send (tea.KeyMsg {Type : tea .KeyDown })
107+ tm .Send (tea.KeyMsg {Type : tea .KeyEnter }) // select second option, "Create New Org"
108+
109+ uitest .WaitForGoldenContains (t , drv , errc ,
110+ "? What is the new organization's name?" ,
111+ )
112+ tm .Send (tea.KeyMsg {
113+ Runes : []rune ("Org Name" ),
114+ Type : tea .KeyRunes ,
115+ })
116+ tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
117+
118+ uitest .WaitForGoldenContains (t , drv , errc ,
119+ "? Which org-slug/realm-slug service's lcl.host local development environment do you want to setup?" ,
120+ )
121+ tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
122+
123+ uitest .WaitForGoldenContains (t , drv , errc ,
124+ "? How would you like to manage your environment variables?" ,
125+ )
126+
127+ tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
128+
129+ tm .WaitFinished (t , teatest .WithFinalTimeout (time .Second * 3 ))
130+
131+ env , err := cmd .clipboard .ReadAll ()
132+ if err != nil {
133+ t .Fatal (err )
134+ }
135+
136+ want := "export ACME_CONTACT=\" [email protected] \" \n export ACME_DIRECTORY_URL=\" https://anchor.dev/org-slug/realm-slug/x509/ca/acme\" \n export ACME_HMAC_KEY=\" abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ\" \n export ACME_KID=\" aae_abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEF\" \n export HTTPS_PORT=\" 4433\" \n export SERVER_NAMES=\" service.lcl.host\" \n " 137+ if got := env ; want != got {
138+ t .Errorf ("Want env clipboard:\n \n %q,\n \n Got:\n \n %q\n \n " , want , got )
139+ }
140+
141+ uitest .TestGolden (t , drv .Golden ())
142+ })
143+
76144 t .Run ("create-service-automated-basics" , func (t * testing.T ) {
77145 if srv .IsMock () {
78146 t .Skip ("lcl setup create service unsupported in mock mode" )
@@ -108,7 +176,10 @@ func TestSetup(t *testing.T) {
108176 "? What is the application name?" ,
109177 )
110178
111- tm .Type ("test-app" )
179+ tm .Send (tea.KeyMsg {
180+ Runes : []rune ("test-app" ),
181+ Type : tea .KeyRunes ,
182+ })
112183 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
113184
114185 uitest .WaitForGoldenContains (t , drv , errc ,
@@ -181,7 +252,6 @@ func TestSetup(t *testing.T) {
181252 uitest .WaitForGoldenContains (t , drv , errc ,
182253 "? Which lcl_setup/localhost service's lcl.host local development environment do you want to setup?" ,
183254 )
184-
185255 tm .Send (tea.KeyMsg {Type : tea .KeyDown })
186256 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
187257
@@ -195,7 +265,10 @@ func TestSetup(t *testing.T) {
195265 "? What is the application name?" ,
196266 )
197267
198- tm .Type ("test-app" )
268+ tm .Send (tea.KeyMsg {
269+ Runes : []rune ("test-app" ),
270+ Type : tea .KeyRunes ,
271+ })
199272 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
200273
201274 uitest .WaitForGoldenContains (t , drv , errc ,
@@ -219,7 +292,7 @@ func TestSetup(t *testing.T) {
219292 }
220293 })
221294
222- t .Run (fmt . Sprintf ( "existing-service-basics-%s" , uitest . TestTagOS ()) , func (t * testing.T ) {
295+ t .Run ("existing-service-basics" , func (t * testing.T ) {
223296 if srv .IsProxy () {
224297 t .Skip ("lcl setup existing service unsupported in proxy mode" )
225298 }
@@ -258,7 +331,15 @@ func TestSetup(t *testing.T) {
258331
259332 tm .WaitFinished (t , teatest .WithFinalTimeout (time .Second * 3 ))
260333
261- // FIXME: check clipboard values for accuracy (can't easily access values)
334+ env , err := cmd .clipboard .ReadAll ()
335+ if err != nil {
336+ t .Fatal (err )
337+ }
338+
339+ want := "export ACME_CONTACT=\" [email protected] \" \n export ACME_DIRECTORY_URL=\" https://anchor.dev/org-slug/realm-slug/x509/ca/acme\" \n export ACME_HMAC_KEY=\" abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ\" \n export ACME_KID=\" aae_abcdefghijklmnopqrstuvwxyz0123456789-_ABCDEF\" \n export HTTPS_PORT=\" 4433\" \n export SERVER_NAMES=\" service.lcl.host\" \n " 340+ if got := env ; want != got {
341+ t .Errorf ("Want env clipboard:\n \n %q,\n \n Got:\n \n %q\n \n " , want , got )
342+ }
262343
263344 uitest .TestGolden (t , drv .Golden ())
264345 })
@@ -305,7 +386,10 @@ func TestSetup(t *testing.T) {
305386 "? What is the application name?" ,
306387 )
307388
308- tm .Type ("Test App" )
389+ tm .Send (tea.KeyMsg {
390+ Runes : []rune ("Test App" ),
391+ Type : tea .KeyRunes ,
392+ })
309393 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
310394
311395 uitest .WaitForGoldenContains (t , drv , errc ,
@@ -370,15 +454,19 @@ func TestSetup(t *testing.T) {
370454 uitest .WaitForGoldenContains (t , drv , errc ,
371455 "? What is the application name?" ,
372456 )
373-
374- tm .Type ("test-explicit-subdomain-app" )
457+ tm .Send (tea.KeyMsg {
458+ Runes : []rune ("test-explicit-subdomain-app" ),
459+ Type : tea .KeyRunes ,
460+ })
375461 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
376462
377463 uitest .WaitForGoldenContains (t , drv , errc ,
378464 "? What lcl.host domain would you like to use for local application development?" ,
379465 )
380-
381- tm .Type ("this-is-my-weird-subdomain" )
466+ tm .Send (tea.KeyMsg {
467+ Runes : []rune ("this-is-my-weird-subdomain" ),
468+ Type : tea .KeyRunes ,
469+ })
382470 tm .Send (tea.KeyMsg {Type : tea .KeyEnter })
383471
384472 uitest .WaitForGoldenContains (t , drv , errc ,
0 commit comments