Skip to content

Commit

Permalink
updated CHANGELOG and added t.Parallel to some of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jan 3, 2024
1 parent 4f24922 commit 1fcc2d8
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## v0.20.3

- Fixed the `json` field query comparisons to work correctly with plain JSON values like `null`, `bool` `number`, etc. ([#4068](https://github.com/pocketbase/pocketbase/issues/4068)).
Since there are plans in the future to allow custom SQLite builds and also in some situations it may be useful to be able to distinguish `NULL` from `''`,
for the `json` fields (and for any other future non-standard field) we no longer apply `COALESCE` by default, aka.:
```
Dataset:
1) data: json(null)
2) data: json('')
For the filter "data = null" only 1) will resolve to TRUE.
For the filter "data = ''" only 2) will resolve to TRUE.
```

- Minor Go tests improvements
- Sorted the record cascade delete references to ensure that the delete operation will preserve the order of the fired events when running the tests.
- Marked some of the tests as safe for parallel execution to speed up a little the GitHub action build times.


## v0.20.2

- Added `sleep(milliseconds)` JSVM binding.
Expand Down
2 changes: 2 additions & 0 deletions cmd/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestAdminCreateCommand(t *testing.T) {
t.Parallel()

app, _ := tests.NewTestApp()
defer app.Cleanup()

Expand Down
2 changes: 2 additions & 0 deletions mails/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestSendAdminPasswordReset(t *testing.T) {
t.Parallel()

testApp, _ := tests.NewTestApp()
defer testApp.Cleanup()

Expand Down
6 changes: 6 additions & 0 deletions mails/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestSendRecordPasswordReset(t *testing.T) {
t.Parallel()

testApp, _ := tests.NewTestApp()
defer testApp.Cleanup()

Expand Down Expand Up @@ -37,6 +39,8 @@ func TestSendRecordPasswordReset(t *testing.T) {
}

func TestSendRecordVerification(t *testing.T) {
t.Parallel()

testApp, _ := tests.NewTestApp()
defer testApp.Cleanup()

Expand All @@ -62,6 +66,8 @@ func TestSendRecordVerification(t *testing.T) {
}

func TestSendRecordChangeEmail(t *testing.T) {
t.Parallel()

testApp, _ := tests.NewTestApp()
defer testApp.Cleanup()

Expand Down
8 changes: 8 additions & 0 deletions models/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import (
)

func TestAdminTableName(t *testing.T) {
t.Parallel()

m := models.Admin{}
if m.TableName() != "_admins" {
t.Fatalf("Unexpected table name, got %q", m.TableName())
}
}

func TestAdminValidatePassword(t *testing.T) {
t.Parallel()

scenarios := []struct {
admin models.Admin
password string
Expand Down Expand Up @@ -61,6 +65,8 @@ func TestAdminValidatePassword(t *testing.T) {
}

func TestAdminSetPassword(t *testing.T) {
t.Parallel()

m := models.Admin{
// 123456
PasswordHash: "$2a$10$SKk/Y/Yc925PBtsSYBvq3Ous9Jy18m4KTn6b/PQQ.Y9QVjy3o/Fv.",
Expand Down Expand Up @@ -93,6 +99,8 @@ func TestAdminSetPassword(t *testing.T) {
}

func TestAdminRefreshTokenKey(t *testing.T) {
t.Parallel()

m := models.Admin{TokenKey: "test"}

m.RefreshTokenKey()
Expand Down
10 changes: 10 additions & 0 deletions models/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestBaseModelHasId(t *testing.T) {
t.Parallel()

scenarios := []struct {
model models.BaseModel
expected bool
Expand Down Expand Up @@ -34,6 +36,8 @@ func TestBaseModelHasId(t *testing.T) {
}

func TestBaseModelId(t *testing.T) {
t.Parallel()

m := models.BaseModel{}

if m.GetId() != "" {
Expand All @@ -54,6 +58,8 @@ func TestBaseModelId(t *testing.T) {
}

func TestBaseModelIsNew(t *testing.T) {
t.Parallel()

m0 := models.BaseModel{}
m1 := models.BaseModel{Id: ""}
m2 := models.BaseModel{Id: "test"}
Expand Down Expand Up @@ -96,6 +102,8 @@ func TestBaseModelIsNew(t *testing.T) {
}

func TestBaseModelCreated(t *testing.T) {
t.Parallel()

m := models.BaseModel{}

if !m.GetCreated().IsZero() {
Expand All @@ -110,6 +118,8 @@ func TestBaseModelCreated(t *testing.T) {
}

func TestBaseModelUpdated(t *testing.T) {
t.Parallel()

m := models.BaseModel{}

if !m.GetUpdated().IsZero() {
Expand Down
28 changes: 28 additions & 0 deletions models/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import (
)

func TestCollectionTableName(t *testing.T) {
t.Parallel()

m := models.Collection{}
if m.TableName() != "_collections" {
t.Fatalf("Unexpected table name, got %q", m.TableName())
}
}

func TestCollectionBaseFilesPath(t *testing.T) {
t.Parallel()

m := models.Collection{}

m.RefreshId()
Expand All @@ -29,6 +33,8 @@ func TestCollectionBaseFilesPath(t *testing.T) {
}

func TestCollectionIsBase(t *testing.T) {
t.Parallel()

scenarios := []struct {
collection models.Collection
expected bool
Expand All @@ -48,6 +54,8 @@ func TestCollectionIsBase(t *testing.T) {
}

func TestCollectionIsAuth(t *testing.T) {
t.Parallel()

scenarios := []struct {
collection models.Collection
expected bool
Expand All @@ -67,6 +75,8 @@ func TestCollectionIsAuth(t *testing.T) {
}

func TestCollectionMarshalJSON(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
collection models.Collection
Expand Down Expand Up @@ -109,6 +119,8 @@ func TestCollectionMarshalJSON(t *testing.T) {
}

func TestCollectionBaseOptions(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
collection models.Collection
Expand Down Expand Up @@ -153,6 +165,8 @@ func TestCollectionBaseOptions(t *testing.T) {
}

func TestCollectionAuthOptions(t *testing.T) {
t.Parallel()

options := types.JsonMap{"test": 123, "minPasswordLength": 4}
expectedSerialization := `{"manageRule":null,"allowOAuth2Auth":false,"allowUsernameAuth":false,"allowEmailAuth":false,"requireEmail":false,"exceptEmailDomains":null,"onlyVerified":false,"onlyEmailDomains":null,"minPasswordLength":4}`

Expand Down Expand Up @@ -200,6 +214,8 @@ func TestCollectionAuthOptions(t *testing.T) {
}

func TestCollectionViewOptions(t *testing.T) {
t.Parallel()

options := types.JsonMap{"query": "select id from demo1", "minPasswordLength": 4}
expectedSerialization := `{"query":"select id from demo1"}`

Expand Down Expand Up @@ -247,6 +263,8 @@ func TestCollectionViewOptions(t *testing.T) {
}

func TestNormalizeOptions(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
collection models.Collection
Expand Down Expand Up @@ -288,6 +306,8 @@ func TestNormalizeOptions(t *testing.T) {
}

func TestDecodeOptions(t *testing.T) {
t.Parallel()

m := models.Collection{
Options: types.JsonMap{"test": 123},
}
Expand All @@ -306,6 +326,8 @@ func TestDecodeOptions(t *testing.T) {
}

func TestSetOptions(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
collection models.Collection
Expand Down Expand Up @@ -357,13 +379,17 @@ func TestSetOptions(t *testing.T) {
}

func TestCollectionBaseOptionsValidate(t *testing.T) {
t.Parallel()

opt := models.CollectionBaseOptions{}
if err := opt.Validate(); err != nil {
t.Fatal(err)
}
}

func TestCollectionAuthOptionsValidate(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
options models.CollectionAuthOptions
Expand Down Expand Up @@ -451,6 +477,8 @@ func TestCollectionAuthOptionsValidate(t *testing.T) {
}

func TestCollectionViewOptionsValidate(t *testing.T) {
t.Parallel()

scenarios := []struct {
name string
options models.CollectionViewOptions
Expand Down
2 changes: 2 additions & 0 deletions models/external_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestExternalAuthTableName(t *testing.T) {
t.Parallel()

m := models.ExternalAuth{}
if m.TableName() != "_externalAuths" {
t.Fatalf("Unexpected table name, got %q", m.TableName())
Expand Down
2 changes: 2 additions & 0 deletions models/param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestParamTableName(t *testing.T) {
t.Parallel()

m := models.Param{}
if m.TableName() != "_params" {
t.Fatalf("Unexpected table name, got %q", m.TableName())
Expand Down
Loading

0 comments on commit 1fcc2d8

Please sign in to comment.