diff --git a/go.mod b/go.mod index 4b130b60..83887311 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/rudderlabs/rudder-go-kit -go 1.22.5 +go 1.22.7 replace github.com/gocql/gocql => github.com/scylladb/gocql v1.14.2 diff --git a/testhelper/gittest/gittest.go b/testhelper/gittest/gittest.go index b35a2227..e7d66371 100644 --- a/testhelper/gittest/gittest.go +++ b/testhelper/gittest/gittest.go @@ -109,6 +109,14 @@ func (s *Server) GetServerCA() []byte { return getServerCA(s.Server) } +func (s *Server) GetLatestCommitHash(t testing.TB, branch string) string { + cmd := exec.Command("git", "ls-remote", s.URL, fmt.Sprintf("refs/heads/%s", branch)) + out, err := cmd.Output() + require.NoError(t, err, "should be able to run the ls-remote command") + commitHash := strings.Split(string(out), "\t")[0] + return commitHash +} + func getServerCA(server *httptest.Server) []byte { return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: server.TLS.Certificates[0].Certificate[0]}) } diff --git a/testhelper/gittest/gittest_test.go b/testhelper/gittest/gittest_test.go index 40084bd0..fd6477e3 100644 --- a/testhelper/gittest/gittest_test.go +++ b/testhelper/gittest/gittest_test.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "testing" "github.com/stretchr/testify/require" @@ -57,6 +58,13 @@ func TestGitServer(t *testing.T) { out, err = execCmd("git", "-C", tempDir, "push", "origin", "v1.0.0") require.NoErrorf(t, err, "should be able to push the tag: %s", out) + + out, err = execCmd("git", "-C", tempDir, "rev-parse", "HEAD") + require.NoError(t, err, "should be able to get the HEAD commit") + require.NotEmpty(t, out, "HEAD commit should not be empty") + + latestCommit := s.GetLatestCommitHash(t, "develop") + require.Equal(t, strings.TrimSpace(out), latestCommit, "HEAD commit should match the latest commit") }) t.Run("https", func(t *testing.T) {