summaryrefslogtreecommitdiffstats
path: root/models/models_test.go
blob: d0f734d678ff838707bbc92768866d83b70d346d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2014 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 models

import (
	"fmt"
	"testing"

	"github.com/lunny/xorm"
	_ "github.com/mattn/go-sqlite3"
)

func init() {
	LoadModelsConfig()
	NewEngine()

	var err error
	orm, err = xorm.NewEngine("sqlite3", "./test.db")
	if err != nil {
		fmt.Println(err)
	}

	orm.ShowSQL = true
	orm.ShowDebug = true

	err = orm.Sync(&User{}, &Repo{})
	if err != nil {
		fmt.Println(err)
	}

	root = "test"
}

func TestCreateRepository(t *testing.T) {
	user := User{Id: 1, Type: Individual}
	_, err := CreateRepository(&user, "test")
	if err != nil {
		t.Error(err)
	}
}

func TestDeleteRepository(t *testing.T) {
	user := User{Id: 1, Type: Individual}
	err := DeleteRepository(&user, "test")
	if err != nil {
		t.Error(err)
	}
}