1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-05 18:40:59 +00:00

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 <gusted@noreply.code.forgejo.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-08-21 19:50:05 +00:00 committed by earl-warren
parent 8eda2e40a4
commit fac8be3c56
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201

View file

@ -37,12 +37,18 @@ func Test_uuidFromSecret(t *testing.T) {
assert.EqualValues(t, uuid, "41414141-4141-4141-4141-414141414141")
}
func Test_ping(t *testing.T) {
cfg := &config.Config{}
func getForgejoFromEnv(t *testing.T) string {
t.Helper()
address := os.Getenv("FORGEJO_URL")
if address == "" {
address = "https://code.forgejo.org"
t.Skip("skipping because FORGEJO_URL is not set")
}
return address
}
func Test_ping(t *testing.T) {
cfg := &config.Config{}
address := getForgejoFromEnv(t)
reg := &config.Registration{
Address: address,
UUID: "create-runner-file_test.go",
@ -51,6 +57,8 @@ func Test_ping(t *testing.T) {
}
func Test_runCreateRunnerFile(t *testing.T) {
instance := getForgejoFromEnv(t)
//
// Set the .runner file to be in a temporary directory
//
@ -63,10 +71,6 @@ func Test_runCreateRunnerFile(t *testing.T) {
assert.NoError(t, err)
assert.NoError(t, os.WriteFile(configFile, yamlData, 0o666))
instance, has := os.LookupEnv("FORGEJO_URL")
if !has {
instance = "https://code.forgejo.org"
}
secret, has := os.LookupEnv("FORGEJO_RUNNER_SECRET")
assert.True(t, has)
name := "testrunner"