MCPcopy Create free account
hub / github.com/anchordotdev/cli / TestBootstrap

Function TestBootstrap

lcl/bootstrap_test.go:51–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestBootstrap(t *testing.T) {
52 ctx, cancel := context.WithCancel(context.Background())
53 defer cancel()
54
55 if err := srv.RecreateUser("lcl_config"); err != nil {
56 t.Fatal(err)
57 }
58
59 cfg := new(cli.Config)
60 if err := cfg.Load(ctx); err != nil {
61 t.Fatal(err)
62 }
63 cfg.API.URL = srv.URL
64 cfg.Test.ACME.URL = "http://anchor.lcl.host:" + srv.RailsPort
65 cfg.Service.APID = "hi-ankydotdev"
66 cfg.Lcl.Diagnostic.Subdomain = "hi-ankydotdev"
67 cfg.Trust.MockMode = true
68 cfg.Trust.NoSudo = true
69 cfg.Trust.Stores = []string{"mock"}
70 var err error
71 if cfg.API.Token, err = srv.GeneratePAT("lcl_config@anchor.dev"); err != nil {
72 t.Fatal(err)
73 }
74 ctx = cli.ContextWithConfig(ctx, cfg)
75
76 _, diagPort, err := net.SplitHostPort(cfg.Lcl.Diagnostic.Addr)
77 if err != nil {
78 t.Fatal(err)
79 }
80 httpURL := "http://hello-world.lcl.host:" + diagPort
81 httpsURL := "https://hello-world.lcl.host:" + diagPort
82
83 t.Run("basics", func(t *testing.T) {
84 ctx, cancel := context.WithCancel(ctx)
85 defer cancel()
86
87 drv, tm := uitest.TestTUI(ctx, t)
88
89 cmd := Bootstrap{}
90
91 errc := make(chan error, 1)
92 go func() {
93 defer close(errc)
94
95 if err := cmd.UI().RunTUI(ctx, drv); err != nil {
96 errc <- err
97 return
98 }
99 errc <- tm.Quit()
100 }()
101
102 // wait for prompt
103
104 uitest.WaitForGoldenContains(t, drv, errc,
105 "? What lcl.host domain would you like to use for diagnostics?",
106 )
107
108 tm.Send(tea.KeyMsg{

Callers

nothing calls this directly

Calls 15

UIMethod · 0.95
ContextWithConfigFunction · 0.92
TestTUIFunction · 0.92
WaitForGoldenContainsFunction · 0.92
TestGoldenFunction · 0.92
RecreateUserMethod · 0.80
LoadMethod · 0.80
GeneratePATMethod · 0.80
SendMethod · 0.80
IsProxyMethod · 0.80
GetMethod · 0.80
GoldenMethod · 0.80

Tested by

no test coverage detected