diff options
Diffstat (limited to 'internal/dbutil/string_test.go')
-rw-r--r-- | internal/dbutil/string_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/dbutil/string_test.go b/internal/dbutil/string_test.go new file mode 100644 index 00000000..ec01f580 --- /dev/null +++ b/internal/dbutil/string_test.go @@ -0,0 +1,25 @@ +// Copyright 2022 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package dbutil + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "gogs.io/gogs/internal/conf" +) + +func TestQuote(t *testing.T) { + conf.UsePostgreSQL = true + got := Quote("SELECT * FROM %s", "user") + want := `SELECT * FROM "user"` + assert.Equal(t, want, got) + conf.UsePostgreSQL = false + + got = Quote("SELECT * FROM %s", "user") + want = `SELECT * FROM user` + assert.Equal(t, want, got) +} |