diff options
author | Joe Chen <jc@unknwon.io> | 2022-11-05 13:12:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 13:12:53 +0800 |
commit | a66c90462da24a916ee62afcb5a1f79d06ed8399 (patch) | |
tree | ac193502864d4f9309e82adf2b883f2d6cdfe879 /internal/dbutil/string_test.go | |
parent | 3af5a424f0e1afa9e77a60376bca97bc5c3b5f8b (diff) |
refactor(db): migrate methods off `user.go` and `org.go` (#7219) (#7227)
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) +} |