Skip to content

Commit

Permalink
test: move to cupaloy for snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent 7609219 commit 0cce70f
Show file tree
Hide file tree
Showing 112 changed files with 1,596 additions and 357 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,8 @@ migrations-render-replace: .bin/ory

.PHONY: migratest-refresh
migratest-refresh:
cd persistence/sql/migratest; go test -tags sqlite,refresh -short .
cd persistence/sql/migratest; UPDATE_SNAPSHOTS=true go test -tags sqlite -short .

.PHONY: test-update-snapshots
test-update-snapshots:
UPDATE_SNAPSHOTS=true go test -tags sqlite -short ./...
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ that your company deserves a spot here, reach out to
<td>DataDetect</td>
<td align="center"><img height="32px" src="https://raw.githubusercontent.com/ory/meta/master/static/adopters/datadetect.svg" alt="Datadetect"></td>
<td><a href="https://unifiedglobalarchiving.com/data-detect/">unifiedglobalarchiving.com/data-detect/</a></td>
</tr>
</tr>
<tr>
<td>Adopter *</td>
<td>Sainsbury's</td>
Expand All @@ -182,13 +182,13 @@ that your company deserves a spot here, reach out to
<td>Reyah</td>
<td align="center"><img height="32px" src="https://raw.githubusercontent.com/ory/meta/master/static/adopters/reyah.svg" alt="Reyah"></td>
<td><a href="https://reyah.eu/">reyah.eu</a></td>
</tr>
</tr>
<tr>
<td>Adopter *</td>
<td>Zero</td>
<td align="center"><img height="32px" src="https://raw.githubusercontent.com/ory/meta/master/static/adopters/commitzero.svg" alt="Project Zero by Commit"></td>
<td><a href="https://getzero.dev/">getzero.dev</a></td>
</tr>
</tr>
<tr>
<td>Adopter *</td>
<td>Padis</td>
Expand All @@ -206,7 +206,7 @@ that your company deserves a spot here, reach out to
<td>Spiri.bo</td>
<td align="center"><img height="32px" src="https://raw.githubusercontent.com/ory/meta/master/static/adopters/spiribo.svg" alt="Spiri.bo"></td>
<td><a href="https://spiri.bo/">spiri.bo</a></td>
</tr>
</tr>
<tr>
<td>Sponsor</td>
<td>Strivacity</td>
Expand Down Expand Up @@ -449,6 +449,14 @@ go test -tags sqlite ./...
cd client; go test -tags sqlite .
```

##### Updating Test Fixtures

Some tests use fixtures. If payloads change, you can update them with:

```
make test-update-snapshots
```

##### End-to-End Tests

We use [Cypress](https://www.cypress.io) to run our e2e tests.
Expand Down
12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module github.com/ory/kratos
go 1.16

replace (
github.com/bradleyjkemp/cupaloy/v2 => github.com/aeneasr/cupaloy/v2 v2.6.1-0.20210924214125-3dfdd01210a3
github.com/gobuffalo/pop/v5 => github.com/gobuffalo/pop/v5 v5.3.4-0.20210608105745-bb07a373cc0e
github.com/luna-duclos/instrumentedsql => github.com/ory/instrumentedsql v1.2.0
github.com/luna-duclos/instrumentedsql/opentracing => github.com/ory/instrumentedsql/opentracing v0.0.0-20210903114257-c8963b546c5c
github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb
github.com/oleiade/reflections => github.com/oleiade/reflections v1.0.1
github.com/gobuffalo/pop/v5 => github.com/gobuffalo/pop/v5 v5.3.4-0.20210608105745-bb07a373cc0e
github.com/luna-duclos/instrumentedsql => github.com/ory/instrumentedsql v1.2.0
github.com/luna-duclos/instrumentedsql/opentracing => github.com/ory/instrumentedsql/opentracing v0.0.0-20210903114257-c8963b546c5c
Expand All @@ -18,9 +24,8 @@ replace (
github.com/gobuffalo/pop/v5 => github.com/gobuffalo/pop/v5 v5.3.4-0.20210608105745-bb07a373cc0e
github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb
github.com/ory/x => github.com/ory/x v0.0.276
github.com/oleiade/reflections => github.com/oleiade/reflections v1.0.1
github.com/luna-duclos/instrumentedsql => github.com/ory/instrumentedsql v1.2.0
github.com/luna-duclos/instrumentedsql/opentracing => github.com/ory/instrumentedsql/opentracing v0.0.0-20210903114257-c8963b546c5c
go.mongodb.org/mongo-driver => go.mongodb.org/mongo-driver v1.4.6
gopkg.in/DataDog/dd-trace-go.v1 => gopkg.in/DataDog/dd-trace-go.v1 v1.27.1-0.20201005154917-54b73b3e126a
)

require (
Expand All @@ -30,6 +35,7 @@ require (
github.com/Masterminds/sprig/v3 v3.0.0
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0
github.com/avast/retry-go/v3 v3.1.1
github.com/bradleyjkemp/cupaloy/v2 v2.3.0
github.com/bwmarrin/discordgo v0.23.0
github.com/bxcodec/faker/v3 v3.3.1
github.com/cenkalti/backoff v2.2.1+incompatible
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:H
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/aeneasr/cupaloy/v2 v2.6.1-0.20210924214125-3dfdd01210a3 h1:/SkiUr3JJzun9QN9cpUVCPri2ZwOFJ3ani+F3vdoCiY=
github.com/aeneasr/cupaloy/v2 v2.6.1-0.20210924214125-3dfdd01210a3/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM=
Expand Down
25 changes: 25 additions & 0 deletions internal/testhelpers/snapshot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package testhelpers

import (
"encoding/json"
"testing"

"github.com/bradleyjkemp/cupaloy/v2"
"github.com/stretchr/testify/require"
"github.com/tidwall/sjson"
)

func SnapshotTExcept(t *testing.T, actual interface{}, except []string) {
compare, err := json.MarshalIndent(actual, "", " ")
require.NoError(t, err, "%+v", actual)
for _, e := range except {
compare, err = sjson.DeleteBytes(compare, e)
require.NoError(t, err, "%s", e)
}

cupaloy.New(
cupaloy.CreateNewAutomatically(true),
cupaloy.FailOnUpdate(true),
cupaloy.SnapshotFileExtension(".json"),
).SnapshotT(t, compare)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"via": "email",
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"status": "pending",
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"status": "pending",
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"status": "pending",
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"status": "pending",
"created_at": "2013-10-07T08:23:19Z",
"updated_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"expires_at": "2013-10-07T08:23:19Z",
"issued_at": "2013-10-07T08:23:19Z",
"request_url": "http://kratos:4433/self-service/browser/flows/login?prompt=login\u0026return_to=http%3A%2F%2F127.0.0.1%3A4455%2F.ory%2Fkratos%2Fpublic%2Fself-service%2Fbrowser%2Fflows%2Fsettings%2Fstrategies%2Fprofile%3Frequest%3D74fd6c53-7651-453e-90b8-2c5adbf911bb",
"return_to": "http://127.0.0.1:4455/.ory/kratos/public/self-service/browser/flows/settings/strategies/profile?request=74fd6c53-7651-453e-90b8-2c5adbf911bb",
"ui": {
"action": "",
"method": "",
Expand All @@ -13,4 +14,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": true,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"updated_at": "2013-10-07T08:23:19Z",
"forced": false,
"requested_aal": "aal1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"nodes": null
},
"state": "choose_method"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"nodes": null
},
"state": "choose_method"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"nodes": null
},
"state": "choose_method"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"nodes": null
},
"state": "choose_method"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"nodes": null
},
"state": "choose_method"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"recovery_address": null,
"expires_at": "2013-10-07T08:23:19Z",
"issued_at": "2013-10-07T08:23:19Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"recovery_address": null,
"expires_at": "2000-01-01T00:00:00Z",
"issued_at": "2000-01-01T00:00:00Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"recovery_address": null,
"expires_at": "2000-01-01T00:00:00Z",
"issued_at": "2000-01-01T00:00:00Z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"method": "",
"nodes": null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"method": "",
"nodes": null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"method": "",
"nodes": null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"method": "",
"nodes": null
}
}
}
Loading

0 comments on commit 0cce70f

Please sign in to comment.