Skip to content
Merged
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
27 changes: 27 additions & 0 deletions cmd/internal/migrations/v3/encryptcookie_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,30 @@ var _ = encryptcookie.New(encryptcookie.Config{
second := readFile(t, file)
assert.Equal(t, first, second)
}

func Test_MigrateEncryptcookieConfig_EncryptorDecryptorMigrated(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test function name Test_MigrateEncryptcookieConfig_EncryptorDecryptorMigrated is a bit inconsistent with the existing Test_MigrateEncryptcookieConfig_Idempotent test. Since this test also verifies idempotency, but for a more specific case, consider renaming it to better reflect its purpose and align with existing test names. A more consistent name could be Test_MigrateEncryptcookieConfig_Idempotent_EncryptorDecryptor. This improves consistency and makes the test suite easier to understand.

Suggested change
func Test_MigrateEncryptcookieConfig_EncryptorDecryptorMigrated(t *testing.T) {
func Test_MigrateEncryptcookieConfig_Idempotent_EncryptorDecryptor(t *testing.T) {

t.Parallel()

dir, err := os.MkdirTemp("", "mencryptcookiealready")
require.NoError(t, err)
defer func() { require.NoError(t, os.RemoveAll(dir)) }()

input := `package main
import (
"github.com/gofiber/fiber/v2/middleware/encryptcookie"
)
var _ = encryptcookie.New(encryptcookie.Config{
Encryptor: func(_ string, value, key string) (string, error) { return "", nil },
Decryptor: func(_ string, value string, key string) (string, error) { return "", nil },
})`

file := writeTempFile(t, dir, input)

var buf bytes.Buffer
cmd := newCmd(&buf)
require.NoError(t, v3.MigrateEncryptcookieConfig(cmd, dir, nil, nil))

content := readFile(t, file)
assert.Equal(t, input, content)
assert.Empty(t, buf.String())
}
Loading