mirror of
https://github.com/goreleaser/nfpm.git
synced 2026-06-19 08:05:04 +00:00
refactor: modernize
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
@@ -139,7 +139,6 @@ func TestDefaultWithArch(t *testing.T) {
|
||||
"etc/fake/fake3.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
|
||||
}
|
||||
for _, arch := range []string{"386", "amd64"} {
|
||||
arch := arch
|
||||
t.Run(arch, func(t *testing.T) {
|
||||
info := exampleInfo()
|
||||
info.Arch = arch
|
||||
|
||||
+1
-3
@@ -95,7 +95,6 @@ func TestConventionalExtension(t *testing.T) {
|
||||
|
||||
func TestArch(t *testing.T) {
|
||||
for _, arch := range []string{"386", "amd64", "arm64"} {
|
||||
arch := arch
|
||||
t.Run(arch, func(t *testing.T) {
|
||||
info := exampleInfo()
|
||||
info.Arch = arch
|
||||
@@ -131,7 +130,6 @@ func TestArchNoInfo(t *testing.T) {
|
||||
|
||||
func TestArchConventionalFileName(t *testing.T) {
|
||||
for _, arch := range []string{"386", "amd64", "arm64"} {
|
||||
arch := arch
|
||||
t.Run(arch, func(t *testing.T) {
|
||||
info := exampleInfo()
|
||||
info.Arch = arch
|
||||
@@ -378,7 +376,7 @@ func TestGlob(t *testing.T) {
|
||||
"./usr/share/nfpm-repro/b/b.txt": {expectedTime, "mode=644", "size=7", "type=file", "md5digest=551a67cc6e06de1910061fe318d28f72", "sha256digest=73a2c64f9545172c1195efb6616ca5f7afd1df6f245407cafb90de3998a1c97f"},
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(string(mtreeContentBts), "\n") {
|
||||
for line := range strings.SplitSeq(string(mtreeContentBts), "\n") {
|
||||
if line == "#mtree" || line == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
+2
-3
@@ -112,7 +112,6 @@ func TestConventionalExtension(t *testing.T) {
|
||||
|
||||
func TestDeb(t *testing.T) {
|
||||
for _, arch := range []string{"386", "amd64"} {
|
||||
arch := arch
|
||||
t.Run(arch, func(t *testing.T) {
|
||||
info := exampleInfo()
|
||||
info.Arch = arch
|
||||
@@ -133,7 +132,7 @@ func TestDebPlatform(t *testing.T) {
|
||||
}
|
||||
|
||||
func extractDebArchitecture(deb *bytes.Buffer) string {
|
||||
for _, s := range strings.Split(deb.String(), "\n") {
|
||||
for s := range strings.SplitSeq(deb.String(), "\n") {
|
||||
if strings.Contains(s, "Architecture: ") {
|
||||
return strings.TrimPrefix(s, "Architecture: ")
|
||||
}
|
||||
@@ -169,7 +168,7 @@ func TestDebArch(t *testing.T) {
|
||||
}
|
||||
|
||||
func extractDebVersion(deb *bytes.Buffer) string {
|
||||
for _, s := range strings.Split(deb.String(), "\n") {
|
||||
for s := range strings.SplitSeq(deb.String(), "\n") {
|
||||
if strings.Contains(s, "Version: ") {
|
||||
return strings.TrimPrefix(s, "Version: ")
|
||||
}
|
||||
|
||||
+2
-4
@@ -283,9 +283,7 @@ contents:
|
||||
t.Cleanup(func() { close(errs) })
|
||||
var wg sync.WaitGroup
|
||||
for range 10 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
_, err := files.PrepareForPackager(
|
||||
config.Contents,
|
||||
0,
|
||||
@@ -294,7 +292,7 @@ contents:
|
||||
mtime,
|
||||
)
|
||||
errs <- err
|
||||
}()
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ var testCases = []struct {
|
||||
func TestPGPSignerAndVerify(t *testing.T) {
|
||||
data := []byte("testdata")
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
armoredPublicKey := fmt.Sprintf("%s.asc", testCase.pubKeyFile)
|
||||
gpgPublicKey := fmt.Sprintf("%s.gpg", testCase.pubKeyFile)
|
||||
@@ -67,7 +66,6 @@ func TestPGPSignerAndVerify(t *testing.T) {
|
||||
func TestArmoredDetachSignAndVerify(t *testing.T) {
|
||||
data := []byte("testdata")
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
armoredPublicKey := fmt.Sprintf("%s.asc", testCase.pubKeyFile)
|
||||
gpgPublicKey := fmt.Sprintf("%s.gpg", testCase.pubKeyFile)
|
||||
|
||||
@@ -23,7 +23,6 @@ func TestRSASignAndVerify(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
sig, err := rsaSign(bytes.NewReader(testData), testCase.privKey, testCase.passphrase)
|
||||
require.NoError(t, err)
|
||||
|
||||
+2
-3
@@ -98,7 +98,6 @@ func TestConventionalExtension(t *testing.T) {
|
||||
|
||||
func TestIPK(t *testing.T) {
|
||||
for _, arch := range []string{"386", "amd64"} {
|
||||
arch := arch
|
||||
t.Run(arch, func(t *testing.T) {
|
||||
info := exampleInfo()
|
||||
info.Arch = arch
|
||||
@@ -119,7 +118,7 @@ func TestIPKPlatform(t *testing.T) {
|
||||
}
|
||||
|
||||
func extractIPKArchitecture(deb *bytes.Buffer) string {
|
||||
for _, s := range strings.Split(deb.String(), "\n") {
|
||||
for s := range strings.SplitSeq(deb.String(), "\n") {
|
||||
if strings.Contains(s, "Architecture: ") {
|
||||
return strings.TrimPrefix(s, "Architecture: ")
|
||||
}
|
||||
@@ -155,7 +154,7 @@ func TestIPKArch(t *testing.T) {
|
||||
}
|
||||
|
||||
func extractIPKVersion(deb *bytes.Buffer) string {
|
||||
for _, s := range strings.Split(deb.String(), "\n") {
|
||||
for s := range strings.SplitSeq(deb.String(), "\n") {
|
||||
if strings.Contains(s, "Version: ") {
|
||||
return strings.TrimPrefix(s, "Version: ")
|
||||
}
|
||||
|
||||
@@ -576,7 +576,6 @@ func TestOverrides(t *testing.T) {
|
||||
require.Equal(t, "amd64", config.Arch)
|
||||
|
||||
for _, format := range []string{"apk", "deb", "rpm"} {
|
||||
format := format
|
||||
t.Run(format, func(t *testing.T) {
|
||||
pkg, err := config.Get(format)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user