diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 19e8553bb2..b66726a3e6 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -1453,51 +1453,34 @@ func TestInitInstructions(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) session := loginUser(t, user.Name) - sha256Repo, _, f := tests.CreateDeclarativeRepoWithOptions(t, user, tests.DeclarativeRepoOptions{ - Name: optional.Some("sha256-instruction"), - AutoInit: optional.Some(false), - EnabledUnits: optional.Some([]unit_model.Type{unit_model.TypeCode}), - ObjectFormat: optional.Some("sha256"), - }) - defer f() - - sha1Repo, _, f := tests.CreateDeclarativeRepoWithOptions(t, user, tests.DeclarativeRepoOptions{ - Name: optional.Some("sha1-instruction"), - AutoInit: optional.Some(false), - EnabledUnits: optional.Some([]unit_model.Type{unit_model.TypeCode}), - ObjectFormat: optional.Some("sha1"), - }) - defer f() - - portMatcher := regexp.MustCompile(`localhost:\d+`) - - t.Run("sha256", func(t *testing.T) { + forEachObjectFormat(t, func(t *testing.T, objectFormat git.ObjectFormat) { defer tests.PrintCurrentTest(t)() + name := objectFormat.Name() + var init string + if name == "sha1" { + init = "git init" + } else { + init = fmt.Sprintf("git init --object-format=%s", name) + } - resp := session.MakeRequest(t, NewRequest(t, "GET", "/"+sha256Repo.FullName()), http.StatusOK) + repo, _, f := tests.CreateDeclarativeRepoWithOptions(t, user, tests.DeclarativeRepoOptions{ + Name: optional.Some(name + "-instruction"), + AutoInit: optional.Some(false), + EnabledUnits: optional.Some([]unit_model.Type{unit_model.TypeCode}), + ObjectFormat: optional.Some(name), + }) + defer f() + + portMatcher := regexp.MustCompile(`localhost:\d+`) + resp := session.MakeRequest(t, NewRequest(t, "GET", "/"+repo.FullName()), http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - assert.Equal(t, `touch README.md -git init --object-format=sha256 + assert.Equal(t, fmt.Sprintf(`touch README.md +%s git switch -c main git add README.md git commit -m "first commit" -git remote add origin http://localhost/user2/sha256-instruction.git -git push -u origin main`, portMatcher.ReplaceAllString(htmlDoc.Find(".empty-repo-guide code").First().Text(), "localhost")) - }) - - t.Run("sha1", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - resp := session.MakeRequest(t, NewRequest(t, "GET", "/"+sha1Repo.FullName()), http.StatusOK) - - htmlDoc := NewHTMLParser(t, resp.Body) - assert.Equal(t, `touch README.md -git init -git switch -c main -git add README.md -git commit -m "first commit" -git remote add origin http://localhost/user2/sha1-instruction.git -git push -u origin main`, portMatcher.ReplaceAllString(htmlDoc.Find(".empty-repo-guide code").First().Text(), "localhost")) +git remote add origin http://localhost/user2/%s-instruction.git +git push -u origin main`, init, name), portMatcher.ReplaceAllString(htmlDoc.Find(".empty-repo-guide code").First().Text(), "localhost")) }) }