1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/client/gitlab_test.go
Manuel Vogel e92bbe32ce feat: full gitlab support for brew and scoop (#1084)
* makes context tokentype a public var

* passes artifacts object into client upload function. extracts gitlab upload hash from url

* adds gitlab url to brew config

* build brew formula depending on token type

* fixes client for release tests

* fixes exiting brew tests

* fixes scoop test with dummy client adaption

* uses new artifact upload hash

* fixes brew usage

* updates gitlab createFile for brew

* fixes logging for non-existing file in gitlab logging

* fix: gitlab createFile

* fix: removes encoding from gitlab create and update file opts

* fix: gitlab upload and artifact set upload hash

* fix: linter

* changed artifact item to a pointer in ctx

* docs: updates homebrew

* feat: enables scoop for gitlab release

* fix: scoop panic for pointer access

* chore: rename formula build func for brew

* chore: brew removes comments

* fix: brew tests

* test: updates brew tests

* docs: updates homebrew

* test: for token type not implemented for brew

* tests: for multiple linux builds

* fix: build artifacts are pointer in scoop

* test: for scoop and gitlab

* test: for artifacts set upload hash

* adds missing files after adaption

* chore: removes and clarifies comments

* fix: moves artifact upload hash to extra map

* adds comment why we initialize the extra map
2019-08-13 15:28:03 -03:00

34 lines
998 B
Go

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")
}
}