mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
6afdb49c12
this will add support to winget into goreleaser. Basically, the plan is: - we generate the 3 needed yaml files - we commit them to a repo and that's it. Initially, will probably have limited options support, and will only have the default locale. ###### TODO - [x] docs - [x] review by someone who knows how this works? - [x] test install somewhere - [x] more tests maybe? - [x] PR templates via API? https://github.com/goreleaser/goreleaser/pull/4105 - [x] real project test - [x] setup goreleaser to pr to winget as well - [x] document sync fork stuff https://github.com/goreleaser/goreleaser/pull/4106 --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
// Package golden asserts golden files contents.
|
|
package golden
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var update = flag.Bool("update", false, "update .golden files")
|
|
|
|
const golden = ".golden"
|
|
|
|
func RequireEqual(tb testing.TB, out []byte) {
|
|
tb.Helper()
|
|
RequireEqualExt(tb, out, "")
|
|
}
|
|
|
|
func RequireEqualExt(tb testing.TB, out []byte, ext string) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ext, golden, false)
|
|
}
|
|
|
|
func RequireEqualExtSubfolder(tb testing.TB, out []byte, ext string) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ext, golden, true)
|
|
}
|
|
|
|
func RequireEqualTxt(tb testing.TB, out []byte) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ".txt", golden, false)
|
|
}
|
|
|
|
func RequireEqualJSON(tb testing.TB, out []byte) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ".json", golden, false)
|
|
}
|
|
|
|
func RequireEqualRb(tb testing.TB, out []byte) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ".rb", golden, false)
|
|
}
|
|
|
|
func RequireEqualYaml(tb testing.TB, out []byte) {
|
|
tb.Helper()
|
|
doRequireEqual(tb, out, ".yaml", "", false)
|
|
}
|
|
|
|
func RequireReadFile(tb testing.TB, path string) []byte {
|
|
tb.Helper()
|
|
bts, err := os.ReadFile(path)
|
|
require.NoError(tb, err)
|
|
return bts
|
|
}
|
|
|
|
func doRequireEqual(tb testing.TB, out []byte, ext, suffix string, folder bool) {
|
|
tb.Helper()
|
|
|
|
golden := filepath.Join("testdata", tb.Name()+ext+suffix)
|
|
if folder {
|
|
golden = filepath.Join("testdata", tb.Name(), filepath.Base(tb.Name())+ext+suffix)
|
|
}
|
|
if *update {
|
|
require.NoError(tb, os.MkdirAll(filepath.Dir(golden), 0o755))
|
|
require.NoError(tb, os.WriteFile(golden, out, 0o655))
|
|
}
|
|
|
|
gbts, err := os.ReadFile(golden)
|
|
require.NoError(tb, err)
|
|
|
|
require.Equal(tb, string(gbts), string(out))
|
|
}
|