-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
omegion
committed
Jun 1, 2021
1 parent
2c800cc
commit 7d7850b
Showing
18 changed files
with
361 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package backup | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type mockStorage struct{} | ||
|
||
func (s *mockStorage) Get(backup Backup) error { return nil } | ||
func (s *mockStorage) Save(backup Backup) error { return nil } | ||
func (s *mockStorage) Delete(backup Backup) error { return nil } | ||
func (s *mockStorage) List(b Backup) ([]Backup, error) { return []Backup{}, nil } | ||
|
||
type mockStorageFailure struct{} | ||
|
||
func (s *mockStorageFailure) Get(backup Backup) error { return errors.New("custom-error") } | ||
func (s *mockStorageFailure) Save(backup Backup) error { return errors.New("custom-error") } | ||
func (s *mockStorageFailure) Delete(backup Backup) error { return errors.New("custom-error") } | ||
func (s *mockStorageFailure) List(b Backup) ([]Backup, error) { | ||
return []Backup{}, errors.New("custom-error") | ||
} | ||
|
||
func TestBackup_Get(t *testing.T) { | ||
storage := mockStorage{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Get(&storage) | ||
|
||
assert.NoError(t, err) | ||
} | ||
|
||
func TestBackup_Get_Failure(t *testing.T) { | ||
storage := mockStorageFailure{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Get(&storage) | ||
|
||
assert.EqualError(t, err, "custom-error") | ||
} | ||
|
||
func TestBackup_Save(t *testing.T) { | ||
storage := mockStorage{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Save(&storage) | ||
|
||
assert.NoError(t, err) | ||
} | ||
|
||
func TestBackup_Save_Failure(t *testing.T) { | ||
storage := mockStorageFailure{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Save(&storage) | ||
|
||
assert.EqualError(t, err, "custom-error") | ||
} | ||
|
||
func TestBackup_Delete(t *testing.T) { | ||
storage := mockStorage{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Delete(&storage) | ||
|
||
assert.NoError(t, err) | ||
} | ||
|
||
func TestBackup_Delete_Failure(t *testing.T) { | ||
storage := mockStorageFailure{} | ||
backup := New(Options{}) | ||
|
||
err := backup.Delete(&storage) | ||
|
||
assert.EqualError(t, err, "custom-error") | ||
} | ||
|
||
func TestBackup_Filename(t *testing.T) { | ||
backup := New(Options{}) | ||
|
||
fileName := backup.Filename() | ||
|
||
assert.Contains(t, fileName, ".sql.tar.gz") | ||
} |
Oops, something went wrong.