2014-02-14 18:16:54 -05:00
|
|
|
// 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.
|
|
|
|
|
2014-02-13 10:23:23 -05:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/lunny/xorm"
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2014-03-21 00:48:10 -05:00
|
|
|
LoadModelsConfig()
|
|
|
|
NewEngine()
|
|
|
|
|
2014-02-13 10:23:23 -05:00
|
|
|
var err error
|
|
|
|
orm, err = xorm.NewEngine("sqlite3", "./test.db")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
|
2014-02-14 09:20:57 -05:00
|
|
|
orm.ShowSQL = true
|
|
|
|
orm.ShowDebug = true
|
|
|
|
|
|
|
|
err = orm.Sync(&User{}, &Repo{})
|
2014-02-13 10:23:23 -05:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2014-02-14 09:20:57 -05:00
|
|
|
|
|
|
|
root = "test"
|
2014-02-13 10:23:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateRepository(t *testing.T) {
|
2014-02-14 09:20:57 -05:00
|
|
|
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")
|
2014-02-13 10:23:23 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|