package opensuse import ( "os" "testing" ) func TestParseServiceHelm(t *testing.T) { b, err := os.ReadFile("testdata/helm/_service") if err != nil { t.Fatal(err) } svcs, err := ParseService(b) if err != nil { t.Fatal(err) } if len(svcs) != 5 { t.Fatalf("services: %+v", svcs) } s := svcs[0] if s.Name != "obs_scm" || s.Mode != "manual" || !s.IsSCM() || s.URL() != "https://github.com/helm/helm.git" { t.Errorf("obs_scm: %+v", s) } if s.Params["revision"] != "refs/tags/v4.3.0" || s.Params["versionformat"] != "@PARENT_TAG@" || s.Params["versionrewrite-pattern"] != "v(.*)" { t.Errorf("params: %v", s.Params) } if svcs[2].Name != "tar" || svcs[2].Mode != "buildtime" || svcs[2].URL() != "" || svcs[2].IsSCM() { t.Errorf("tar: %+v", svcs[2]) } if svcs[3].Params["compression"] != "gz" { t.Errorf("recompress: %+v", svcs[3]) } } func TestParseServiceVariants(t *testing.T) { svcs, err := ParseService([]byte(` https://github.com/cli/cli git v2.100.0 https example.org /dl/x-1.0.tar.gz `)) if err != nil { t.Fatal(err) } if len(svcs) != 3 || svcs[0].URL() != "https://github.com/cli/cli" || !svcs[0].IsSCM() || svcs[0].Mode != "disabled" { t.Errorf("tar_scm: %+v", svcs) } if svcs[1].URL() != "https://example.org/dl/x-1.0.tar.gz" || svcs[1].IsSCM() { t.Errorf("download_url: %+v", svcs[1]) } if svcs[2].URL() != "" { t.Errorf("download_files: %+v", svcs[2]) } if _, err := ParseService([]byte("