(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestValidateUsername(t *testing.T) { |
| 103 | if env := os.Getenv("TRAVIS"); env == "true" { |
| 104 | t.Skip("Travis environment: avoiding non authenticated requests") |
| 105 | } |
| 106 | if _, has := os.LookupEnv("CI"); has { |
| 107 | t.Skip("Github action environment: avoiding non authenticated requests") |
| 108 | } |
| 109 | |
| 110 | tests := []struct { |
| 111 | name string |
| 112 | input string |
| 113 | fixed string |
| 114 | ok bool |
| 115 | }{ |
| 116 | { |
| 117 | name: "existing username", |
| 118 | input: "git-bug", |
| 119 | fixed: "git-bug", |
| 120 | ok: true, |
| 121 | }, |
| 122 | { |
| 123 | name: "existing username with bad case", |
| 124 | input: "GiT-bUg", |
| 125 | fixed: "git-bug", |
| 126 | ok: true, |
| 127 | }, |
| 128 | { |
| 129 | name: "existing organisation", |
| 130 | input: "git-bug", |
| 131 | fixed: "git-bug", |
| 132 | ok: true, |
| 133 | }, |
| 134 | { |
| 135 | name: "existing organisation with bad case", |
| 136 | input: "gIt-BuG", |
| 137 | fixed: "git-bug", |
| 138 | ok: true, |
| 139 | }, |
| 140 | { |
| 141 | name: "non existing username", |
| 142 | input: "cant-find-this", |
| 143 | fixed: "", |
| 144 | ok: false, |
| 145 | }, |
| 146 | } |
| 147 | |
| 148 | for _, tt := range tests { |
| 149 | t.Run(tt.name, func(t *testing.T) { |
| 150 | ok, fixed, err := validateUsername(tt.input) |
| 151 | assert.NoError(t, err) |
| 152 | assert.Equal(t, tt.ok, ok) |
| 153 | assert.Equal(t, tt.fixed, fixed) |
| 154 | }) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func TestValidateProject(t *testing.T) { |
| 159 | envPrivate := os.Getenv("GITHUB_TOKEN_PRIVATE") |
nothing calls this directly
no test coverage detected