(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestNewCmdEdit(t *testing.T) { |
| 21 | tests := []struct { |
| 22 | name string |
| 23 | args string |
| 24 | wantOpts EditOptions |
| 25 | wantErr string |
| 26 | }{ |
| 27 | { |
| 28 | name: "change repo description", |
| 29 | args: "--description hello", |
| 30 | wantOpts: EditOptions{ |
| 31 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 32 | Edits: EditRepositoryInput{ |
| 33 | Description: sp("hello"), |
| 34 | }, |
| 35 | }, |
| 36 | }, |
| 37 | { |
| 38 | name: "deny public visibility change without accepting consequences", |
| 39 | args: "--visibility public", |
| 40 | wantOpts: EditOptions{ |
| 41 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 42 | Edits: EditRepositoryInput{}, |
| 43 | }, |
| 44 | wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag", |
| 45 | }, |
| 46 | { |
| 47 | name: "allow public visibility change with accepting consequences", |
| 48 | args: "--visibility public --accept-visibility-change-consequences", |
| 49 | wantOpts: EditOptions{ |
| 50 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 51 | Edits: EditRepositoryInput{ |
| 52 | Visibility: sp("public"), |
| 53 | }, |
| 54 | }, |
| 55 | }, |
| 56 | { |
| 57 | name: "deny private visibility change without accepting consequences", |
| 58 | args: "--visibility private", |
| 59 | wantOpts: EditOptions{ |
| 60 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 61 | Edits: EditRepositoryInput{}, |
| 62 | }, |
| 63 | wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag", |
| 64 | }, |
| 65 | { |
| 66 | name: "allow private visibility change with accepting consequences", |
| 67 | args: "--visibility private --accept-visibility-change-consequences", |
| 68 | wantOpts: EditOptions{ |
| 69 | Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"), |
| 70 | Edits: EditRepositoryInput{ |
| 71 | Visibility: sp("private"), |
| 72 | }, |
| 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | name: "deny internal visibility change without accepting consequences", |
| 77 | args: "--visibility internal", |
nothing calls this directly
no test coverage detected