string_test.go 759 B

1234567891011121314151617181920212223242526272829
  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 and LICENSE.gogs file.
  4. // Copyright 2025 Huan-Gogs Authors. All rights reserved.
  5. // Use of this source code is governed by a MIT-style
  6. // license that can be found in the LICENSE file.
  7. package dbutil
  8. import (
  9. "testing"
  10. "github.com/stretchr/testify/assert"
  11. "github.com/SongZihuan/huan-gogs/internal/conf"
  12. )
  13. func TestQuote(t *testing.T) {
  14. conf.UsePostgreSQL = true
  15. got := Quote("SELECT * FROM %s", "user")
  16. want := `SELECT * FROM "user"`
  17. assert.Equal(t, want, got)
  18. conf.UsePostgreSQL = false
  19. got = Quote("SELECT * FROM %s", "user")
  20. want = `SELECT * FROM user`
  21. assert.Equal(t, want, got)
  22. }