Skip to content

Commit 899c547

Browse files
fix tests on mac arm64 (version 0.10 of resticprofile wasn't built for darwin_arm64)
1 parent da79215 commit 899c547

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

detect_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package selfupdate
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
stdlog "log"
87
"os"
@@ -47,7 +46,7 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
4746
require.NoError(t, err)
4847
assert.True(t, ok, "Failed to detect latest")
4948
require.NotNil(t, r, "No release returned")
50-
if r.LessThan("0.10.0") {
49+
if r.LessThan("0.14.0") {
5150
t.Error("Incorrect version:", r.Version())
5251
}
5352
if !strings.HasSuffix(r.AssetURL, ".zip") && !strings.HasSuffix(r.AssetURL, ".tar.gz") {
@@ -64,7 +63,7 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
6463
}
6564

6665
func TestDetectVersionExisting(t *testing.T) {
67-
testVersion := "v0.10.0"
66+
testVersion := "v0.14.0"
6867
gitHub, _ := NewUpdater(Config{Validator: &ChecksumValidator{UniqueFilename: "checksums.txt"}})
6968
testData := []struct {
7069
run bool
@@ -91,7 +90,7 @@ func TestDetectVersionExisting(t *testing.T) {
9190
}
9291

9392
func TestDetectVersionExistingWithNoValidationFile(t *testing.T) {
94-
testVersion := "v0.10.0"
93+
testVersion := "v0.14.0"
9594
gitHub, _ := NewUpdater(Config{Validator: &ChecksumValidator{UniqueFilename: "notfound.txt"}})
9695
testData := []struct {
9796
run bool
@@ -109,8 +108,7 @@ func TestDetectVersionExistingWithNoValidationFile(t *testing.T) {
109108
t.Run(testItem.name, func(t *testing.T) {
110109
_, _, err := testItem.updater.DetectVersion(context.Background(), testGithubRepository, testVersion)
111110
skipRateLimitExceeded(t, err)
112-
require.Error(t, err)
113-
assert.True(t, errors.Is(err, ErrValidationAssetNotFound))
111+
assert.ErrorIs(t, err, ErrValidationAssetNotFound)
114112
})
115113
}
116114
}
@@ -796,7 +794,7 @@ func TestFindReleaseAndAsset(t *testing.T) {
796794
}
797795

798796
func TestBuildMultistepValidationChain(t *testing.T) {
799-
testVersion := "v0.10.0"
797+
testVersion := "v0.14.0"
800798
source, keyRing := mockPGPSourceRepository(t)
801799
checksumValidator := &ChecksumValidator{UniqueFilename: "checksums.txt"}
802800

@@ -840,6 +838,10 @@ func TestBuildMultistepValidationChain(t *testing.T) {
840838

841839
func newMockUpdater(t *testing.T, config Config) *Updater {
842840
t.Helper()
841+
842+
if config.Source == nil {
843+
config.Source = mockSourceRepository(t)
844+
}
843845
updater, err := NewUpdater(config)
844846
require.NoError(t, err)
845847
return updater

mockdata_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,35 @@ func mockSourceRepository(t *testing.T) *MockSource {
5757
},
5858
},
5959
&GitHubRelease{
60-
name: "v0.10.0",
61-
tagName: "v0.10.0",
62-
url: "v0.10.0",
60+
name: "v0.14.0",
61+
tagName: "v0.14.0",
62+
url: "v0.14.0",
6363
prerelease: false,
6464
publishedAt: time.Date(2010, 1, 1, 0, 0, 0, 0, time.UTC),
6565
releaseNotes: "latest stable",
6666
assets: []SourceAsset{
6767
&GitHubAsset{
6868
id: 4,
69-
name: "resticprofile_0.10.0_linux_amd64.tar.gz",
70-
url: "resticprofile_0.10.0_linux_amd64.tar.gz",
69+
name: "resticprofile_0.14.0_linux_amd64.tar.gz",
70+
url: "resticprofile_0.14.0_linux_amd64.tar.gz",
7171
size: len(gzData),
7272
},
7373
&GitHubAsset{
7474
id: 5,
75-
name: "resticprofile_0.10.0_darwin_amd64.tar.gz",
76-
url: "resticprofile_0.10.0_darwin_amd64.tar.gz",
75+
name: "resticprofile_0.14.0_darwin_amd64.tar.gz",
76+
url: "resticprofile_0.14.0_darwin_amd64.tar.gz",
7777
size: len(gzData),
7878
},
7979
&GitHubAsset{
8080
id: 6,
81-
name: "resticprofile_0.10.0_windows_amd64.zip",
82-
url: "resticprofile_0.10.0_windows_amd64.zip",
81+
name: "resticprofile_0.14.0_windows_amd64.zip",
82+
url: "resticprofile_0.14.0_windows_amd64.zip",
8383
size: len(zipData),
8484
},
8585
&GitHubAsset{
8686
id: 32,
87-
name: "resticprofile_0.10.0_darwin_arm64.tar.gz",
88-
url: "resticprofile_0.10.0_darwin_arm64.tar.gz",
87+
name: "resticprofile_0.14.0_darwin_arm64.tar.gz",
88+
url: "resticprofile_0.14.0_darwin_arm64.tar.gz",
8989
size: len(gzData),
9090
},
9191
},
@@ -273,7 +273,7 @@ func mockSourceRepository(t *testing.T) *MockSource {
273273
name: "checksums.txt",
274274
})
275275
files[id] = checksums.Bytes()
276-
t.Logf("file id %d contains checksums:\n%s\n", id, string(files[id]))
276+
// t.Logf("file id %d contains checksums:\n%s\n", id, string(files[id]))
277277
}
278278

279279
return NewMockSource(releases, files)

update_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestUpdateCommandWithWrongVersion(t *testing.T) {
2222
}
2323

2424
func TestUpdateCommand(t *testing.T) {
25-
current := "0.10.0"
25+
current := "0.14.0"
2626
new := "1.0.0"
2727
source := mockSourceRepository(t)
2828
updater, err := NewUpdater(Config{Source: source})
@@ -42,7 +42,7 @@ func TestUpdateViaSymlink(t *testing.T) {
4242
t.Skip("skipping because creating symlink on windows requires admin privilege")
4343
}
4444

45-
current := "0.10.0"
45+
current := "0.14.0"
4646
new := "1.0.0"
4747
source := mockSourceRepository(t)
4848
updater, err := NewUpdater(Config{Source: source})
@@ -91,7 +91,7 @@ func TestUpdateBrokenSymlinks(t *testing.T) {
9191
defer os.Remove(xxx)
9292

9393
for _, filename := range []string{yyy, xxx} {
94-
_, err := updater.UpdateCommand(context.Background(), filename, "0.10.0", ParseSlug("owner/repo"))
94+
_, err := updater.UpdateCommand(context.Background(), filename, "0.14.0", ParseSlug("owner/repo"))
9595
assert.Error(t, err)
9696
assert.Contains(t, err.Error(), "failed to resolve symlink")
9797
}
@@ -416,7 +416,7 @@ func TestUpdateToSuccess(t *testing.T) {
416416
}
417417

418418
func TestUpdateToWithMultistepValidationChain(t *testing.T) {
419-
testVersion := "v0.10.0"
419+
testVersion := "v0.14.0"
420420
source, keyRing := mockPGPSourceRepository(t)
421421
updater, _ := NewUpdater(Config{
422422
Source: source,

0 commit comments

Comments
 (0)