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.

50 lines
876 B

10 years ago
10 years ago
10 years ago
10 years ago
  1. // Copyright 2014 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 models
  5. import (
  6. "fmt"
  7. "testing"
  8. "github.com/lunny/xorm"
  9. _ "github.com/mattn/go-sqlite3"
  10. )
  11. func init() {
  12. LoadModelsConfig()
  13. NewEngine()
  14. var err error
  15. orm, err = xorm.NewEngine("sqlite3", "./test.db")
  16. if err != nil {
  17. fmt.Println(err)
  18. }
  19. orm.ShowSQL = true
  20. orm.ShowDebug = true
  21. err = orm.Sync(&User{}, &Repo{})
  22. if err != nil {
  23. fmt.Println(err)
  24. }
  25. root = "test"
  26. }
  27. func TestCreateRepository(t *testing.T) {
  28. user := User{Id: 1, Type: Individual}
  29. _, err := CreateRepository(&user, "test")
  30. if err != nil {
  31. t.Error(err)
  32. }
  33. }
  34. func TestDeleteRepository(t *testing.T) {
  35. user := User{Id: 1, Type: Individual}
  36. err := DeleteRepository(&user, "test")
  37. if err != nil {
  38. t.Error(err)
  39. }
  40. }