(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestDelete(t *testing.T) { |
| 19 | now, _ := time.Parse(time.RFC3339, "2021-09-22T00:00:00Z") |
| 20 | daysAgo := func(n int) string { |
| 21 | return now.Add(time.Hour * -time.Duration(24*n)).Format(time.RFC3339) |
| 22 | } |
| 23 | |
| 24 | tests := []struct { |
| 25 | name string |
| 26 | opts deleteOptions |
| 27 | codespaces []*api.Codespace |
| 28 | confirms map[string]bool |
| 29 | deleteErr error |
| 30 | wantErr string |
| 31 | wantDeleted []string |
| 32 | wantStdout string |
| 33 | wantStderr string |
| 34 | }{ |
| 35 | { |
| 36 | name: "by name", |
| 37 | opts: deleteOptions{ |
| 38 | codespaceName: "hubot-robawt-abc", |
| 39 | }, |
| 40 | codespaces: []*api.Codespace{ |
| 41 | { |
| 42 | Name: "hubot-robawt-abc", |
| 43 | }, |
| 44 | }, |
| 45 | wantDeleted: []string{"hubot-robawt-abc"}, |
| 46 | wantStderr: "1 codespace(s) deleted successfully\n", |
| 47 | }, |
| 48 | { |
| 49 | name: "by repo", |
| 50 | opts: deleteOptions{ |
| 51 | repoFilter: "monalisa/spoon-knife", |
| 52 | }, |
| 53 | codespaces: []*api.Codespace{ |
| 54 | { |
| 55 | Name: "monalisa-spoonknife-123", |
| 56 | Repository: api.Repository{ |
| 57 | FullName: "monalisa/Spoon-Knife", |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | Name: "hubot-robawt-abc", |
| 62 | Repository: api.Repository{ |
| 63 | FullName: "hubot/ROBAWT", |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | Name: "monalisa-spoonknife-c4f3", |
| 68 | Repository: api.Repository{ |
| 69 | FullName: "monalisa/Spoon-Knife", |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | wantDeleted: []string{"monalisa-spoonknife-123", "monalisa-spoonknife-c4f3"}, |
| 74 | wantStderr: "2 codespace(s) deleted successfully\n", |
| 75 | }, |
nothing calls this directly
no test coverage detected