1
0

string_test.go 560 B

12345678910111213141516171819202122232425
  1. // Copyright 2022 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package dbutil
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "gogs.io/gogs/internal/conf"
  9. )
  10. func TestQuote(t *testing.T) {
  11. conf.UsePostgreSQL = true
  12. got := Quote("SELECT * FROM %s", "user")
  13. want := `SELECT * FROM "user"`
  14. assert.Equal(t, want, got)
  15. conf.UsePostgreSQL = false
  16. got = Quote("SELECT * FROM %s", "user")
  17. want = `SELECT * FROM user`
  18. assert.Equal(t, want, got)
  19. }