Add tests

This commit is contained in:
Andrew Cassidy 2025-10-11 23:54:04 -07:00
parent 9f2b142992
commit 41f3020420
No known key found for this signature in database

View file

@ -280,6 +280,40 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) {
})
}
func TestRunContext_GetGithubContextURL(t *testing.T) {
table := []struct {
instance string
serverUrl string
APIUrl string
}{
{instance: "", serverUrl: "", APIUrl: "/api/v1"},
{instance: "example.com", serverUrl: "https://example.com", APIUrl: "https://example.com/api/v1"},
{instance: "http://example.com", serverUrl: "http://example.com", APIUrl: "http://example.com/api/v1"},
{instance: "https://example.com", serverUrl: "https://example.com", APIUrl: "https://example.com/api/v1"},
}
for _, data := range table {
t.Run(data.instance, func(t *testing.T) {
rc := &RunContext{
EventJSON: "{}",
Config: &Config{
GitHubInstance: data.instance,
},
Run: &model.Run{
Workflow: &model.Workflow{
Name: "GitHubContextTest",
},
},
}
ghc := rc.getGithubContext(t.Context())
assert.Equal(t, data.serverUrl, ghc.ServerURL)
assert.Equal(t, data.APIUrl, ghc.APIURL)
})
}
}
func TestRunContext_GetGithubContextRef(t *testing.T) {
table := []struct {
event string