1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/internal/client/gitlab_test.go

34 lines
998 B
Go
Raw Normal View History

package client
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtractHashFromProjectFileURL(t *testing.T) {
givenHash := "22e8b1508b0f28433b94754a5ea2f4aa"
projectFileURL := fmt.Sprintf("/uploads/%s/release-testing_0.3.7_Darwin_x86_64.tar.gz", givenHash)
extractedHash, err := extractProjectFileHashFrom(projectFileURL)
if err != nil {
t.Errorf("expexted no error but got: %v", err)
}
assert.Equal(t, givenHash, extractedHash)
}
func TestFailToExtractHashFromProjectFileURL(t *testing.T) {
givenHash := "22e8b1508b0f28433b94754a5ea2f4aa"
projectFileURL := fmt.Sprintf("/uploads/%s/new-path/file.ext", givenHash)
_, err := extractProjectFileHashFrom(projectFileURL)
if err == nil {
t.Errorf("expected an error but got none for new-path in url")
}
projectFileURL = fmt.Sprintf("/%s/file.ext", givenHash)
_, err = extractProjectFileHashFrom(projectFileURL)
if err == nil {
t.Errorf("expected an error but got none for path-too-small in url")
}
}