-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable minor schema version updates (#141)
* enable minor schema version updates * use schema version type * in anticipation of future major minor schema v * add unit test * correct major minor * comments * correct schema version * using newer schema versions
- Loading branch information
1 parent
8286d77
commit 6a3dd4a
Showing
3 changed files
with
92 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sqlite_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/canonical/k8s-dqlite/pkg/kine/drivers/sqlite" | ||
) | ||
|
||
func TestCanMigrate(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
current sqlite.SchemaVersion | ||
target sqlite.SchemaVersion | ||
canMigrate bool | ||
expectedErr error | ||
}{ | ||
{ | ||
name: "can not migrate between different major versions", | ||
current: sqlite.NewSchemaVersion(0, 0), | ||
target: sqlite.NewSchemaVersion(1, 0), | ||
expectedErr: fmt.Errorf("can not migrate between different major versions"), | ||
}, | ||
{ | ||
name: "can migrate", | ||
current: sqlite.NewSchemaVersion(0, 0), | ||
target: sqlite.NewSchemaVersion(0, 1), | ||
expectedErr: nil, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.current.CompatibleWith(tt.target) | ||
if err != nil && tt.expectedErr == nil { | ||
if err.Error() != tt.expectedErr.Error() { | ||
t.Errorf("expected error %v, got %v", tt.expectedErr, err) | ||
} | ||
} | ||
}) | ||
} | ||
} |
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