Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: use testing helpers for env and cleanup #992

Merged
merged 1 commit into from
Aug 4, 2023
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
39 changes: 14 additions & 25 deletions tests/integration/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package integration

import (
"testing"

"github.com/kong/deck/utils"
"github.com/stretchr/testify/assert"
"testing"
)

var (
Expand Down Expand Up @@ -473,8 +474,7 @@ func Test_Diff_Workspace_OlderThan3x(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", "<3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

_, err := diff(tc.stateFile)
assert.NoError(t, err)
Expand All @@ -498,8 +498,7 @@ func Test_Diff_Workspace_NewerThan3x(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

_, err := diff(tc.stateFile)
assert.NoError(t, err)
Expand Down Expand Up @@ -530,8 +529,7 @@ func Test_Diff_Masked_OlderThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", "==2.8.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -548,8 +546,7 @@ func Test_Diff_Masked_OlderThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", "==2.8.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand Down Expand Up @@ -584,8 +581,7 @@ func Test_Diff_Masked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -601,8 +597,7 @@ func Test_Diff_Masked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -618,8 +613,7 @@ func Test_Diff_Masked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.1.0 <3.4.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand Down Expand Up @@ -654,8 +648,7 @@ func Test_Diff_Unmasked_OlderThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", "==2.8.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -671,8 +664,7 @@ func Test_Diff_Unmasked_OlderThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", "==2.8.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand Down Expand Up @@ -707,8 +699,7 @@ func Test_Diff_Unmasked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -724,8 +715,7 @@ func Test_Diff_Unmasked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand All @@ -741,8 +731,7 @@ func Test_Diff_Unmasked_NewerThan3x(t *testing.T) {
t.Setenv(k, v)
}
runWhen(t, "kong", ">=3.1.0 <3.4.0")
teardown := setup(t)
defer teardown(t)
setup(t)

// initialize state
assert.NoError(t, sync(tc.initialStateFile))
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func Test_Dump_SelectTags_30(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)
setup(t)

assert.NoError(t, sync(tc.stateFile))

Expand Down Expand Up @@ -57,8 +56,7 @@ func Test_Dump_SelectTags_3x(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.1.0")
teardown := setup(t)
defer teardown(t)
setup(t)

assert.NoError(t, sync(tc.stateFile))

Expand Down Expand Up @@ -130,8 +128,7 @@ func Test_Dump_SkipConsumers(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
tc.runWhen(t)
teardown := setup(t)
defer teardown(t)
setup(t)

assert.NoError(t, sync(tc.stateFile))

Expand Down Expand Up @@ -183,8 +180,7 @@ func Test_Dump_SkipConsumers_Konnect(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhenKonnect(t)
teardown := setup(t)
defer teardown(t)
setup(t)

assert.NoError(t, sync(tc.stateFile))

Expand Down
6 changes: 2 additions & 4 deletions tests/integration/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func Test_Reset_SkipCACert_2x(t *testing.T) {
// here because the schema changed and the entities aren't the same
// across all versions, even though the skip functionality works the same.
runWhen(t, "kong", ">=2.7.0 <3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

sync(tc.kongFile)
reset(t, "--skip-ca-certificates")
Expand Down Expand Up @@ -99,8 +98,7 @@ func Test_Reset_SkipCACert_3x(t *testing.T) {
// here because the schema changed and the entities aren't the same
// across all versions, even though the skip functionality works the same.
runWhen(t, "kong", ">=3.0.0")
teardown := setup(t)
defer teardown(t)
setup(t)

sync(tc.kongFile)
reset(t, "--skip-ca-certificates")
Expand Down
Loading
Loading