Skip to content

Commit d68ff8a

Browse files
committed
test: clean nondeterministic values
1 parent 511b735 commit d68ff8a

12 files changed

+1706
-1553
lines changed

test/lib/columns.ts

+128-50
Large diffs are not rendered by default.

test/lib/extensions.ts

+105-69
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,121 @@ import { pgMeta } from './utils'
22

33
test('list', async () => {
44
const res = await pgMeta.extensions.list()
5-
expect(res.data?.find(({ name }) => name === 'hstore')).toMatchInlineSnapshot(`
6-
Object {
7-
"comment": "data type for storing sets of (key, value) pairs",
8-
"default_version": "1.7",
9-
"installed_version": null,
10-
"name": "hstore",
11-
"schema": null,
12-
}
13-
`)
5+
expect(res.data?.find(({ name }) => name === 'hstore')).toMatchInlineSnapshot(
6+
{ default_version: expect.stringMatching(/^\d+.\d+$/) },
7+
`
8+
Object {
9+
"comment": "data type for storing sets of (key, value) pairs",
10+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
11+
"installed_version": null,
12+
"name": "hstore",
13+
"schema": null,
14+
}
15+
`
16+
)
1417
})
1518

1619
test('retrieve, create, update, delete', async () => {
1720
const { data: testSchema } = await pgMeta.schemas.create({ name: 'extensions' })
1821

1922
let res = await pgMeta.extensions.create({ name: 'hstore', version: '1.4' })
20-
expect(res).toMatchInlineSnapshot(`
21-
Object {
22-
"data": Object {
23-
"comment": "data type for storing sets of (key, value) pairs",
24-
"default_version": "1.7",
25-
"installed_version": "1.4",
26-
"name": "hstore",
27-
"schema": "public",
28-
},
29-
"error": null,
30-
}
31-
`)
23+
expect(res).toMatchInlineSnapshot(
24+
{
25+
data: {
26+
default_version: expect.stringMatching(/^\d+.\d+$/),
27+
},
28+
},
29+
`
30+
Object {
31+
"data": Object {
32+
"comment": "data type for storing sets of (key, value) pairs",
33+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
34+
"installed_version": "1.4",
35+
"name": "hstore",
36+
"schema": "public",
37+
},
38+
"error": null,
39+
}
40+
`
41+
)
3242
res = await pgMeta.extensions.retrieve({ name: res.data!.name })
33-
expect(res).toMatchInlineSnapshot(`
34-
Object {
35-
"data": Object {
36-
"comment": "data type for storing sets of (key, value) pairs",
37-
"default_version": "1.7",
38-
"installed_version": "1.4",
39-
"name": "hstore",
40-
"schema": "public",
41-
},
42-
"error": null,
43-
}
44-
`)
43+
expect(res).toMatchInlineSnapshot(
44+
{
45+
data: {
46+
default_version: expect.stringMatching(/^\d+.\d+$/),
47+
},
48+
},
49+
`
50+
Object {
51+
"data": Object {
52+
"comment": "data type for storing sets of (key, value) pairs",
53+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
54+
"installed_version": "1.4",
55+
"name": "hstore",
56+
"schema": "public",
57+
},
58+
"error": null,
59+
}
60+
`
61+
)
4562
res = await pgMeta.extensions.update(res.data!.name, { update: true, schema: 'extensions' })
46-
expect(res).toMatchInlineSnapshot(`
47-
Object {
48-
"data": Object {
49-
"comment": "data type for storing sets of (key, value) pairs",
50-
"default_version": "1.7",
51-
"installed_version": "1.7",
52-
"name": "hstore",
53-
"schema": "extensions",
54-
},
55-
"error": null,
56-
}
57-
`)
63+
expect(res).toMatchInlineSnapshot(
64+
{
65+
data: {
66+
default_version: expect.stringMatching(/^\d+.\d+$/),
67+
installed_version: expect.stringMatching(/^\d+.\d+$/),
68+
},
69+
},
70+
`
71+
Object {
72+
"data": Object {
73+
"comment": "data type for storing sets of (key, value) pairs",
74+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
75+
"installed_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
76+
"name": "hstore",
77+
"schema": "extensions",
78+
},
79+
"error": null,
80+
}
81+
`
82+
)
5883
res = await pgMeta.extensions.remove(res.data!.name)
59-
expect(res).toMatchInlineSnapshot(`
60-
Object {
61-
"data": Object {
62-
"comment": "data type for storing sets of (key, value) pairs",
63-
"default_version": "1.7",
64-
"installed_version": "1.7",
65-
"name": "hstore",
66-
"schema": "extensions",
67-
},
68-
"error": null,
69-
}
70-
`)
84+
expect(res).toMatchInlineSnapshot(
85+
{
86+
data: {
87+
default_version: expect.stringMatching(/^\d+.\d+$/),
88+
installed_version: expect.stringMatching(/^\d+.\d+$/),
89+
},
90+
},
91+
`
92+
Object {
93+
"data": Object {
94+
"comment": "data type for storing sets of (key, value) pairs",
95+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
96+
"installed_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
97+
"name": "hstore",
98+
"schema": "extensions",
99+
},
100+
"error": null,
101+
}
102+
`
103+
)
71104
res = await pgMeta.extensions.retrieve({ name: res.data!.name })
72-
expect(res).toMatchInlineSnapshot(`
73-
Object {
74-
"data": Object {
75-
"comment": "data type for storing sets of (key, value) pairs",
76-
"default_version": "1.7",
77-
"installed_version": null,
78-
"name": "hstore",
79-
"schema": null,
80-
},
81-
"error": null,
82-
}
83-
`)
105+
expect(res).toMatchInlineSnapshot(
106+
{ data: { default_version: expect.stringMatching(/^\d+.\d+$/) } },
107+
`
108+
Object {
109+
"data": Object {
110+
"comment": "data type for storing sets of (key, value) pairs",
111+
"default_version": StringMatching /\\^\\\\d\\+\\.\\\\d\\+\\$/,
112+
"installed_version": null,
113+
"name": "hstore",
114+
"schema": null,
115+
},
116+
"error": null,
117+
}
118+
`
119+
)
84120

85121
await pgMeta.schemas.remove(testSchema!.id)
86122
})

0 commit comments

Comments
 (0)