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
}
}
}

0 comments on commit 0cce70f

Please sign in to comment.