Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions appservices/appservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,7 @@ func CheckResponse(r *http.Response) error {

return errorResponse
}

func pointer[T any](x T) *T {
return &x
}
53 changes: 26 additions & 27 deletions appservices/event_triggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"testing"

"github.com/go-test/deep"
"github.com/openlyinc/pointy"
)

func TestEventTriggers_List(t *testing.T) {
Expand Down Expand Up @@ -57,7 +56,7 @@ func TestEventTriggers_List(t *testing.T) {
Type: "type",
FunctionID: "1",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
},
}

Expand Down Expand Up @@ -99,7 +98,7 @@ func TestEventTriggers_Get(t *testing.T) {
Type: "type",
FunctionID: "1",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
}

if diff := deep.Equal(trigger, &expected); diff != nil {
Expand All @@ -118,20 +117,20 @@ func TestEventTriggers_CreateDatabase(t *testing.T) {
Name: "Test event trigger",
Type: "DATABASE",
FunctionID: "60c2badbbd2b5c170e91292d",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: &EventTriggerConfig{
OperationTypes: []string{"INSERT", "UPDATE", "REPLACE", "DELETE"},
Database: "database",
Collection: "collection",
ServiceID: "60c2badbbd2b5c170e91292c",
Match: `{"updateDescription.updatedFields.status": {"$exists": true}}`,
Project: `{"updateDescription.updatedFields.FieldA": 1, "operationType": 1}`,
FullDocument: pointy.Bool(false),
FullDocumentBeforeChange: pointy.Bool(false),
TolerateResumeErrors: pointy.Bool(true),
SkipCatchupEvents: pointy.Bool(true),
MaximumThroughput: pointy.Bool(true),
Unordered: pointy.Bool(false),
FullDocument: pointer(false),
FullDocumentBeforeChange: pointer(false),
TolerateResumeErrors: pointer(true),
SkipCatchupEvents: pointer(true),
MaximumThroughput: pointer(true),
Unordered: pointer(false),
},
EventProcessors: map[string]interface{}{
"AWS_EVENTBRIDGE": map[string]interface{}{
Expand Down Expand Up @@ -239,7 +238,7 @@ func TestEventTriggers_CreateDatabase(t *testing.T) {
Type: "DATABASE",
FunctionID: "60c2badbbd2b5c170e91292d",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: EventTriggerConfig{
OperationTypes: []string{"INSERT", "UPDATE", "REPLACE", "DELETE"},
Database: "sample_airbnb",
Expand All @@ -254,12 +253,12 @@ func TestEventTriggers_CreateDatabase(t *testing.T) {
"operationType": float64(1),
"updateDescription.updatedFields.FieldA": float64(1),
},
FullDocument: pointy.Bool(false),
FullDocumentBeforeChange: pointy.Bool(false),
Unordered: pointy.Bool(false),
TolerateResumeErrors: pointy.Bool(true),
SkipCatchupEvents: pointy.Bool(true),
MaximumThroughput: pointy.Bool(true),
FullDocument: pointer(false),
FullDocumentBeforeChange: pointer(false),
Unordered: pointer(false),
TolerateResumeErrors: pointer(true),
SkipCatchupEvents: pointer(true),
MaximumThroughput: pointer(true),
ClusterName: "cluster name",
},
EventProcessors: map[string]interface{}{
Expand All @@ -271,7 +270,7 @@ func TestEventTriggers_CreateDatabase(t *testing.T) {
},
},
},
LastModified: pointy.Int64(int64(1623793011)),
LastModified: pointer(int64(1623793011)),
}

if diff := deep.Equal(updatedEventTriggersServiceOp, &expected); diff != nil {
Expand All @@ -290,7 +289,7 @@ func TestEventTriggers_CreateAuthentication(t *testing.T) {
Name: "Test event trigger",
Type: "AUTHENTICATION",
FunctionID: "60c2badbbd2b5c170e91292d",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: &EventTriggerConfig{
OperationType: "LOGIN",
Providers: []string{"anon-user", "local-userpass"},
Expand Down Expand Up @@ -379,7 +378,7 @@ func TestEventTriggers_CreateAuthentication(t *testing.T) {
Type: "AUTHENTICATION",
FunctionID: "60c2badbbd2b5c170e91292d",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: EventTriggerConfig{
OperationType: "LOGIN",
Providers: []string{"anon-user", "local-userpass"},
Expand All @@ -395,7 +394,7 @@ func TestEventTriggers_CreateAuthentication(t *testing.T) {
},
},
},
LastModified: pointy.Int64(int64(1623793011)),
LastModified: pointer(int64(1623793011)),
}

if diff := deep.Equal(updatedEventTriggersServiceOp, &expected); diff != nil {
Expand All @@ -414,7 +413,7 @@ func TestEventTriggers_CreateScheduled(t *testing.T) {
Name: "Test event trigger",
Type: "SCHEDULED",
FunctionID: "60c2badbbd2b5c170e91292d",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: &EventTriggerConfig{
Schedule: "* * * * *",
},
Expand Down Expand Up @@ -496,7 +495,7 @@ func TestEventTriggers_CreateScheduled(t *testing.T) {
Type: "SCHEDULED",
FunctionID: "60c2badbbd2b5c170e91292d",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: EventTriggerConfig{
Schedule: "* * * * *",
ScheduleType: "ADVANCED",
Expand All @@ -510,7 +509,7 @@ func TestEventTriggers_CreateScheduled(t *testing.T) {
},
},
},
LastModified: pointy.Int64(int64(1623793011)),
LastModified: pointer(int64(1623793011)),
}

if diff := deep.Equal(updatedEventTriggersServiceOp, &expected); diff != nil {
Expand All @@ -530,7 +529,7 @@ func TestEventTriggers_Update(t *testing.T) {
Name: "Test event trigger update",
Type: "Test event trigger update",
FunctionID: "1",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
Config: &EventTriggerConfig{
OperationTypes: []string{"INSERT", "UPDATE"},
OperationType: "CREATE",
Expand All @@ -540,7 +539,7 @@ func TestEventTriggers_Update(t *testing.T) {
ServiceID: "3",
Match: `{"updateDescription.updatedFields.status": {"$exists": true}}`,
Project: `{"updateDescription.updatedFields.FieldA": 1, "operationType": 1}`,
FullDocument: pointy.Bool(false),
FullDocument: pointer(false),
Schedule: "weekday",
},
EventProcessors: map[string]interface{}{
Expand Down Expand Up @@ -616,7 +615,7 @@ func TestEventTriggers_Update(t *testing.T) {
Type: "type",
FunctionID: "1",
FunctionName: "name",
Disabled: pointy.Bool(false),
Disabled: pointer(false),
}

if diff := deep.Equal(updatedEventTriggersServiceOp, &expected); diff != nil {
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ toolchain go1.23.1
require (
github.com/go-test/deep v1.1.1
github.com/google/go-querystring v1.1.0
github.com/openlyinc/pointy v1.2.0
go.mongodb.org/atlas v0.37.0
)

require github.com/stretchr/testify v1.4.0 // indirect

// Incorrect release versioning
retract v1.0.0
12 changes: 0 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/openlyinc/pointy v1.2.0 h1:vbb/WoPbshyTH8j3/XYu3enlZfv+NHxAD15qTm1zbk0=
github.com/openlyinc/pointy v1.2.0/go.mod h1:JodZOTJoBNaAQHeU0F/SwA4PL0lg4pKF7fYFpX291P0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
go.mongodb.org/atlas v0.37.0 h1:zQnO1o5+bVP9IotpAYpres4UjMD2F4nwNEFTZhNL4ck=
go.mongodb.org/atlas v0.37.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Loading