Skip to content

Commit fac8be3

Browse files
earl-warrenearl-warren
authored andcommitted
chore: skip tests that require Forgejo if it is not available (#902)
<!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/902): <!--number 902 --><!--line 0 --><!--description Y2hvcmU6IHNraXAgdGVzdHMgdGhhdCByZXF1aXJlIEZvcmdlam8gaWYgaXQgaXMgbm90IGF2YWlsYWJsZQ==-->chore: skip tests that require Forgejo if it is not available<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/902 Reviewed-by: Gusted <[email protected]> Reviewed-by: Mathieu Fenniak <[email protected]> Reviewed-by: Michael Kriese <[email protected]> Co-authored-by: Earl Warren <[email protected]> Co-committed-by: Earl Warren <[email protected]>
1 parent 8eda2e4 commit fac8be3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/app/cmd/create-runner-file_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ func Test_uuidFromSecret(t *testing.T) {
3737
assert.EqualValues(t, uuid, "41414141-4141-4141-4141-414141414141")
3838
}
3939

40-
func Test_ping(t *testing.T) {
41-
cfg := &config.Config{}
40+
func getForgejoFromEnv(t *testing.T) string {
41+
t.Helper()
4242
address := os.Getenv("FORGEJO_URL")
4343
if address == "" {
44-
address = "https://code.forgejo.org"
44+
t.Skip("skipping because FORGEJO_URL is not set")
4545
}
46+
return address
47+
}
48+
49+
func Test_ping(t *testing.T) {
50+
cfg := &config.Config{}
51+
address := getForgejoFromEnv(t)
4652
reg := &config.Registration{
4753
Address: address,
4854
UUID: "create-runner-file_test.go",
@@ -51,6 +57,8 @@ func Test_ping(t *testing.T) {
5157
}
5258

5359
func Test_runCreateRunnerFile(t *testing.T) {
60+
instance := getForgejoFromEnv(t)
61+
5462
//
5563
// Set the .runner file to be in a temporary directory
5664
//
@@ -63,10 +71,6 @@ func Test_runCreateRunnerFile(t *testing.T) {
6371
assert.NoError(t, err)
6472
assert.NoError(t, os.WriteFile(configFile, yamlData, 0o666))
6573

66-
instance, has := os.LookupEnv("FORGEJO_URL")
67-
if !has {
68-
instance = "https://code.forgejo.org"
69-
}
7074
secret, has := os.LookupEnv("FORGEJO_RUNNER_SECRET")
7175
assert.True(t, has)
7276
name := "testrunner"

0 commit comments

Comments
 (0)