(t *testing.T)
| 26 | } |
| 27 | |
| 28 | func TestCreateOrg(t *testing.T) { |
| 29 | ctx, cancel := context.WithCancel(context.Background()) |
| 30 | defer cancel() |
| 31 | |
| 32 | cfg := new(cli.Config) |
| 33 | cfg.API.URL = srv.URL |
| 34 | var err error |
| 35 | if cfg.API.Token, err = srv.GeneratePAT("anky@anchor.dev"); err != nil { |
| 36 | t.Fatal(err) |
| 37 | } |
| 38 | ctx = cli.ContextWithConfig(ctx, cfg) |
| 39 | |
| 40 | t.Run("basics", func(t *testing.T) { |
| 41 | if srv.IsProxy() { |
| 42 | t.Skip("org create unsupported in proxy mode") |
| 43 | } |
| 44 | |
| 45 | ctx, cancel := context.WithCancel(ctx) |
| 46 | defer cancel() |
| 47 | |
| 48 | drv, tm := uitest.TestTUI(ctx, t) |
| 49 | |
| 50 | cmd := Create{} |
| 51 | |
| 52 | errc := make(chan error, 1) |
| 53 | go func() { |
| 54 | errc <- cmd.UI().RunTUI(ctx, drv) |
| 55 | errc <- tm.Quit() |
| 56 | }() |
| 57 | |
| 58 | uitest.WaitForGoldenContains(t, drv, errc, |
| 59 | "? What is the new organization's name?", |
| 60 | ) |
| 61 | tm.Send(tea.KeyMsg{ |
| 62 | Runes: []rune("Org Name"), |
| 63 | Type: tea.KeyRunes, |
| 64 | }) |
| 65 | tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) |
| 66 | |
| 67 | tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3)) |
| 68 | uitest.TestGolden(t, drv.Golden()) |
| 69 | }) |
| 70 | } |
nothing calls this directly
no test coverage detected