-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
42 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,44 @@ | ||
test_suite "versions" { | ||
before { | ||
do { | ||
inputs = { | ||
schema = "testing" | ||
} | ||
|
||
migrate "up" { migration_set = migration_set.versions } | ||
migrate "down" { | ||
migration_set = migration_set.versions | ||
inputs = { version = "v2" } | ||
} | ||
migrate "up" { migration_set = migration_set.versions } | ||
} | ||
} | ||
} | ||
|
||
test "versions" "version_inc()" { | ||
set { | ||
search_path = "testing" | ||
} | ||
|
||
it "increases `major` component by default when no type specified" { | ||
do { | ||
sql = "SELECT version_inc(row(1,1,1)::sem_version) AS ver" | ||
} | ||
|
||
row "0" { | ||
column "ver" { assert = "(2,0,0)" } | ||
col "must be 2.0.0" { assert = "ver = row(2,0,0)::sem_version" } | ||
} | ||
} | ||
|
||
it "increases `major` component and resets `minor` and `patch`" { | ||
do { sql = "SELECT version_inc(row(1,1,1)::sem_version, 'major') AS ver" } | ||
|
||
row "0" { | ||
column "ver" { assert = "ver = row(2,0,0)::sem_version" } | ||
col "must be 2.0.0" { assert = "ver = row(2,0,0)::sem_version" } | ||
} | ||
} | ||
|
||
describe "increases `minor` component and resets `patch` leaving `major` untouched" { | ||
it "increases `minor` component and resets `patch` leaving `major` untouched" { | ||
do { sql = "SELECT version_inc(row(1,1,1)::sem_version, 'minor') AS ver" } | ||
|
||
# v1 - set scope | ||
row "0" { | ||
it "ver" { expect = "ver = row(2,0,0)::sem_version" } | ||
its { expect = "ver = row(2,0,0)::sem_version" } | ||
col "must be 1.2.0" { assert = "ver = row(1,2,0)::sem_version" } | ||
} | ||
|
||
# v2 | ||
it "0" "ver" { expect = "ver = row(2,0,0)::sem_version" } | ||
its "0" { expect = "ver = row(2,0,0)::sem_version" } | ||
} | ||
|
||
it "increases `patch` component and leaves `major` and `minor` untouched" { | ||
do { sql = "SELECT version_inc(row(1,1,1)::sem_version, 'patch') AS ver" } | ||
|
||
row "0" { | ||
column "ver" { assert = "(1,1,2)" } | ||
col "must be 1.1.2" { assert = "ver = row(1,1,2)::sem_version" } | ||
} | ||
} | ||
|
||
/* it "raises error when increasing invalid component" { */ | ||
/* do { sql = "SELECT version_inc(row(1,1,1)::sem_version, 'invalid') AS ver" } */ | ||
|
||
/* rows { */ | ||
/* raises_error { */ | ||
/* message = "Failed to increase version using type = 'invalid' for version 1.1.1" */ | ||
/* } */ | ||
/* } */ | ||
/* } */ | ||
|
||
it "returns null on null input" { | ||
do { sql = "SELECT version_inc(null) AS ver" } | ||
|
||
row "0" { | ||
column "ver" { assert = null } | ||
col "must be null" { assert = "ver IS NULL" } | ||
} | ||
} | ||
} |
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,31 @@ | ||
test "versions" "version_inc()" { | ||
query "SELECT version_inc(row(1,1,1)::sem_version) AS ver" { | ||
row "0" { | ||
it "increases major version, resets others" { assert = "ver = row(2,0,0)::sem_version" } | ||
} | ||
} | ||
|
||
query "SELECT version_inc(row(1,1,1)::sem_version, 'major') AS ver" { | ||
row "0" { | ||
it "increases major version, resets others" { assert = "ver = row(2,0,0)::sem_version" } | ||
} | ||
} | ||
|
||
query "SELECT version_inc(row(1,1,1)::sem_version, 'minor') AS ver" { | ||
row "0" { | ||
it "increases minor, resets patch" { assert = "ver = row(1,2,0)::sem_version" } | ||
} | ||
} | ||
|
||
query "SELECT version_inc(row(1,1,1)::sem_version, 'patch') AS ver" { | ||
row "0" { | ||
it "increases patch" { assert = "ver = row(1,1,2)::sem_version" } | ||
} | ||
} | ||
|
||
query "SELECT version_inc(null) AS ver" { | ||
row "0" { | ||
it "returns null on null input" { assert = "ver IS NULL" } | ||
} | ||
} | ||
} |