mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
storage/s3: fix checker prefix (#1239)
This commit is contained in:
@@ -25,6 +25,7 @@ func RunTests(t *testing.T, b storage.Backend, clearBackend func() error) {
|
||||
testDelete(t, b)
|
||||
testGet(t, b)
|
||||
testExists(t, b)
|
||||
testShouldNotExist(t, b)
|
||||
testCatalog(t, b)
|
||||
}
|
||||
|
||||
@@ -166,6 +167,24 @@ func testExists(t *testing.T, b storage.Backend) {
|
||||
require.Equal(t, true, exists)
|
||||
}
|
||||
|
||||
func testShouldNotExist(t *testing.T, b storage.Backend) {
|
||||
ctx := context.Background()
|
||||
mod := "shouldNotExist"
|
||||
ver := "v1.2.3-pre.1"
|
||||
mock := getMockModule()
|
||||
zipBts, _ := ioutil.ReadAll(mock.Zip)
|
||||
err := b.Save(ctx, mod, ver, mock.Mod, bytes.NewReader(zipBts), mock.Info)
|
||||
require.NoError(t, err, "should successfully safe a mock module")
|
||||
defer b.Delete(ctx, mod, ver)
|
||||
|
||||
prefixVer := "v1.2.3-pre"
|
||||
exists, err := b.Exists(ctx, mod, prefixVer)
|
||||
require.NoError(t, err)
|
||||
if exists {
|
||||
t.Fatal("a non existing version that has the same prefix of an existing version should not exist")
|
||||
}
|
||||
}
|
||||
|
||||
// testDelete tests that a module can be deleted from a
|
||||
// storage Backend and the the Exists method returns false
|
||||
// afterwards.
|
||||
|
||||
Reference in New Issue
Block a user