Skip to content

Commit

Permalink
Merge pull request #39 from creativeprojects/macos-arm64
Browse files Browse the repository at this point in the history
Run tests under macOs arm64
  • Loading branch information
creativeprojects authored Mar 19, 2024
2 parents 03cb6bc + 80d8da5 commit c39124e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
go_version: ['1.21', '1.22']
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-14]

steps:

Expand Down
16 changes: 10 additions & 6 deletions detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestDetectReleaseWithVersionPrefix(t *testing.T) {
skipRateLimitExceeded(t, err)
require.NoError(t, err)
assert.True(t, ok, "Failed to detect latest")
assert.NotNil(t, r, "No release returned")
require.NotNil(t, r, "No release returned")
if r.LessThan("0.10.0") {
t.Error("Incorrect version:", r.Version())
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestDetectVersionExisting(t *testing.T) {
skipRateLimitExceeded(t, err)
require.NoError(t, err)
assert.Truef(t, ok, "Failed to detect %s", testVersion)
assert.NotNil(t, r, "No release returned")
require.NotNil(t, r, "No release returned")
assert.Greater(t, r.ValidationAssetID, int64(-1))
})
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestDetectPrerelease(t *testing.T) {
Prerelease: testFixture.prerelease,
})
r, ok, err := updater.DetectLatest(context.Background(), RepositorySlug{owner: "owner", repo: "repo"})
assert.NotNil(t, r)
require.NotNil(t, r)
assert.True(t, ok)
assert.NoError(t, err)

Expand All @@ -176,12 +176,16 @@ func TestDetectReleasesForVariousArchives(t *testing.T) {
{"rhysd-test/test-release-tar-xz", "release-"},
} {
t.Run(tc.slug, func(t *testing.T) {
r, ok, err := DetectLatest(context.Background(), ParseSlug(tc.slug))
source, err := NewGitHubSource(GitHubConfig{})
require.NoError(t, err, "failed to create source")
updater, err := NewUpdater(Config{Source: source, Arch: "amd64"})
require.NoError(t, err, "failed to create updater")
r, ok, err := updater.DetectLatest(context.Background(), ParseSlug(tc.slug))
skipRateLimitExceeded(t, err)

assert.NoError(t, err, "fetch failed")
assert.True(t, ok, "not found")
assert.NotNil(t, r, "release not detected")
require.NotNil(t, r, "release not detected")
assert.Truef(t, r.Equal("1.2.3"), "incorrect release: expected 1.2.3 but got %v", r.Version())

url := fmt.Sprintf("https://github.com/%s/releases/tag/%s1.2.3", tc.slug, tc.prefix)
Expand Down Expand Up @@ -803,7 +807,7 @@ func TestBuildMultistepValidationChain(t *testing.T) {
})

release, found, err := updater.DetectVersion(context.Background(), testGithubRepository, testVersion)
assert.True(t, found)
require.True(t, found)
assert.NoError(t, err)
assert.Equal(t, 2, len(release.ValidationChain))
assert.Equal(t, "checksums.txt", release.ValidationChain[0].ValidationAssetName)
Expand Down
42 changes: 42 additions & 0 deletions mockdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_0.1.0_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 31,
name: "resticprofile_0.1.0_darwin_arm64.tar.gz",
url: "resticprofile_0.1.0_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
&GitHubRelease{
Expand Down Expand Up @@ -76,6 +82,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_0.10.0_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 32,
name: "resticprofile_0.10.0_darwin_arm64.tar.gz",
url: "resticprofile_0.10.0_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
&GitHubRelease{
Expand Down Expand Up @@ -104,6 +116,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_1.0.0-rc_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 33,
name: "resticprofile_1.0.0-rc_darwin_arm64.tar.gz",
url: "resticprofile_1.0.0-rc_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
&GitHubRelease{
Expand Down Expand Up @@ -132,6 +150,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_1.0.0_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 34,
name: "resticprofile_1.0.0_darwin_arm64.tar.gz",
url: "resticprofile_1.0.0_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
&GitHubRelease{
Expand Down Expand Up @@ -160,6 +184,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_2.0.0-beta_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 35,
name: "resticprofile_2.0.0-beta_darwin_arm64.tar.gz",
url: "resticprofile_2.0.0-beta_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
&GitHubRelease{
Expand Down Expand Up @@ -188,6 +218,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
url: "resticprofile_2.0.0_windows_amd64.zip",
size: len(zipData),
},
&GitHubAsset{
id: 36,
name: "resticprofile_2.0.0_darwin_arm64.tar.gz",
url: "resticprofile_2.0.0_darwin_arm64.tar.gz",
size: len(gzData),
},
},
},
}
Expand All @@ -211,6 +247,12 @@ func mockSourceRepository(t *testing.T) *MockSource {
24: gzData,
25: gzData,
26: zipData,
31: gzData,
32: gzData,
33: gzData,
34: gzData,
35: gzData,
36: gzData,
}

// generates checksum files automatically
Expand Down
7 changes: 7 additions & 0 deletions update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func TestBrokenBinaryUpdate(t *testing.T) {
},
&GitHubAsset{
id: 3,
name: "invalid_v2.0.0_darwin_arm64.tar.gz",
url: "invalid_v2.0.0_darwin_arm64.tar.gz",
size: len("invalid content"),
},
&GitHubAsset{
id: 4,
name: "invalid_v2.0.0_windows_amd64.zip",
url: "invalid_v2.0.0_windows_amd64.zip",
size: len("invalid content"),
Expand All @@ -166,6 +172,7 @@ func TestBrokenBinaryUpdate(t *testing.T) {
1: []byte("invalid content"),
2: []byte("invalid content"),
3: []byte("invalid content"),
4: []byte("invalid content"),
})

updater, err := NewUpdater(Config{Source: source})
Expand Down

0 comments on commit c39124e

Please sign in to comment.