garm-provider-edge-connect/internal/spec/spec_test.go
Christopher Hase 0b01584122
Some checks failed
Go Tests / go-tests (push) Failing after 1m10s
feat(client): fix envs
2025-09-09 14:42:39 +02:00

47 lines
1.7 KiB
Go

package spec_test
import (
"testing"
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/internal/spec"
)
func TestExtractGitHubScopeDetails(t *testing.T) {
gitRepoURL := "https://github.com/gabriel-samfira/scripts"
details, err := spec.ExtractGitHubScopeDetails(gitRepoURL)
if err != nil {
t.Errorf("An error occurred: %v", err)
}
if details.BaseURL != "https://github.com" {
t.Errorf(`ExtractGitHubScopeDetails("https://github.com/gabriel-samfira/scripts").BaseURL = %s, want match for %s`, details.BaseURL, "https://github.com")
}
if details.Org != "gabriel-samfira" {
t.Errorf(`ExtractGitHubScopeDetails("https://github.com/gabriel-samfira/scripts").Org = %s, want match for %s`, details.Org, "gabriel-samfira")
}
if details.Repo != "scripts" {
t.Errorf(`ExtractGitHubScopeDetails("https://github.com/gabriel-samfira/scripts").Repo = %s, want match for %s`, details.Repo, "scripts")
}
}
func TestExtractGitHubScopeDetails_Gitea(t *testing.T) {
gitRepoURL := "https://gitea.com/Christopher.Hase/garm-test"
details, err := spec.ExtractGitHubScopeDetails(gitRepoURL)
if err != nil {
t.Errorf("An error occurred: %v", err)
}
if details.BaseURL != "https://gitea.com" {
t.Errorf(`ExtractGitHubScopeDetails("https://gitea.com/Christopher.Hase/garm-test").BaseURL = %s, want match for %s`, details.BaseURL, "https://gitea.com")
}
if details.Org != "Christopher.Hase" {
t.Errorf(`ExtractGitHubScopeDetails("https://gitea.com/Christopher.Hase/garm-test").Org = %s, want match for %s`, details.Org, "Christopher.Hase")
}
if details.Repo != "garm-test" {
t.Errorf(`ExtractGitHubScopeDetails("https://gitea.com/Christopher.Hase/garm-test").Repo = %s, want match for %s`, details.Repo, "garm-test")
}
}