THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
833B

  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestCacheTag(t *testing.T) {
  10. assert.NoError(t, prepareEngine())
  11. type CacheDomain struct {
  12. Id int64 `xorm:"pk cache"`
  13. Name string
  14. }
  15. assert.NoError(t, testEngine.CreateTables(&CacheDomain{}))
  16. assert.True(t, testEngine.GetCacher(testEngine.TableName(&CacheDomain{})) != nil)
  17. }
  18. func TestNoCacheTag(t *testing.T) {
  19. assert.NoError(t, prepareEngine())
  20. type NoCacheDomain struct {
  21. Id int64 `xorm:"pk nocache"`
  22. Name string
  23. }
  24. assert.NoError(t, testEngine.CreateTables(&NoCacheDomain{}))
  25. assert.True(t, testEngine.GetCacher(testEngine.TableName(&NoCacheDomain{})) == nil)
  26. }