(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestSetup(t *testing.T) { |
| 56 | ctx, cancel := context.WithCancel(context.Background()) |
| 57 | defer cancel() |
| 58 | |
| 59 | // ensure lcl_setup has no leftover data |
| 60 | err := srv.RecreateUser("lcl_setup") |
| 61 | if err != nil { |
| 62 | t.Fatal(err) |
| 63 | } |
| 64 | |
| 65 | cfg := cmdtest.Config(ctx) |
| 66 | cfg.API.URL = srv.URL |
| 67 | if srv.IsProxy() { |
| 68 | cfg.Test.ACME.URL = "http://anchor.lcl.host:" + srv.RailsPort |
| 69 | } |
| 70 | cfg.Trust.MockMode = true |
| 71 | cfg.Trust.NoSudo = true |
| 72 | cfg.Trust.Stores = []string{"mock"} |
| 73 | if cfg.API.Token, err = srv.GeneratePAT("lcl_setup@anchor.dev"); err != nil { |
| 74 | t.Fatal(err) |
| 75 | } |
| 76 | ctx = cli.ContextWithConfig(ctx, cfg) |
| 77 | |
| 78 | truststore.ResetMockCAs() |
| 79 | t.Cleanup(truststore.ResetMockCAs) |
| 80 | |
| 81 | setupGuideURL := cfg.SetupGuideURL("lcl_setup", "test-app") |
| 82 | |
| 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{ |
nothing calls this directly
no test coverage detected