altered database code to use repo_host instead of repo_remote
This commit is contained in:
parent
779987da7f
commit
cfed6505d5
4 changed files with 10 additions and 5 deletions
|
@ -59,7 +59,7 @@ var stmts = []string{`
|
||||||
,repo_timeout INTEGER
|
,repo_timeout INTEGER
|
||||||
,repo_created INTEGER
|
,repo_created INTEGER
|
||||||
,repo_updated INTEGER
|
,repo_updated INTEGER
|
||||||
,UNIQUE(repo_remote, repo_owner, repo_name)
|
,UNIQUE(repo_host, repo_owner, repo_name)
|
||||||
);`, `
|
);`, `
|
||||||
CREATE TABLE IF NOT EXISTS commits (
|
CREATE TABLE IF NOT EXISTS commits (
|
||||||
commit_id INTEGER PRIMARY KEY AUTOINCREMENT
|
commit_id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||||
|
|
2
server/database/testdata/testdata.go
vendored
2
server/database/testdata/testdata.go
vendored
|
@ -15,7 +15,7 @@ var stmts = []string{
|
||||||
// insert repository entries
|
// insert repository entries
|
||||||
"insert into repos values (1, 0, 'github.com', 'github.com', 'lhofstadter', 'lenwoloppali', '', 'git://github.com/lhofstadter/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
"insert into repos values (1, 0, 'github.com', 'github.com', 'lhofstadter', 'lenwoloppali', '', 'git://github.com/lhofstadter/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
||||||
"insert into repos values (2, 0, 'github.com', 'github.com', 'browndynamite', 'lenwoloppali', '', 'git://github.com/browndynamite/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
"insert into repos values (2, 0, 'github.com', 'github.com', 'browndynamite', 'lenwoloppali', '', 'git://github.com/browndynamite/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
||||||
"insert into repos values (3, 0, 'gitlab.com', 'github.com', 'browndynamite', 'lenwoloppali', '', 'git://gitlab.com/browndynamite/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
"insert into repos values (3, 0, 'gitlab.com', 'gitlab.com', 'browndynamite', 'lenwoloppali', '', 'git://gitlab.com/browndynamite/lenwoloppali.git', '', '', 1, 1, 1, 1, 1, 'publickey', 'privatekey', 'params', 900, 1398065343, 1398065344);",
|
||||||
|
|
||||||
// insert user + repository permission entries
|
// insert user + repository permission entries
|
||||||
"insert into perms values (1, 101, 200, 1, 1, 1, 1398065343, 1398065344);",
|
"insert into perms values (1, 101, 200, 1, 1, 1, 1398065343, 1398065344);",
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (db *repoManager) Find(id int64) (*Repo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *repoManager) FindName(remote, owner, name string) (*Repo, error) {
|
func (db *repoManager) FindName(remote, owner, name string) (*Repo, error) {
|
||||||
const query = "select * from repos where repo_remote = ? and repo_owner = ? and repo_name = ?"
|
const query = "select * from repos where repo_host = ? and repo_owner = ? and repo_name = ?"
|
||||||
var repo = Repo{}
|
var repo = Repo{}
|
||||||
var err = meddler.QueryRow(db, &repo, query, remote, owner, name)
|
var err = meddler.QueryRow(db, &repo, query, remote, owner, name)
|
||||||
return &repo, err
|
return &repo, err
|
||||||
|
|
|
@ -80,8 +80,8 @@ func TestInsert(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify unique remote + owner + name login constraint
|
// verify unique remote + owner + name login constraint
|
||||||
var err = repos.Insert(&Repo{Remote: repo.Remote, Owner: repo.Owner, Name: repo.Name})
|
var err = repos.Insert(&Repo{Host: repo.Host, Owner: repo.Owner, Name: repo.Name})
|
||||||
if err == nil || !strings.Contains(err.Error(), "repo_remote, repo_owner, repo_name are not unique") {
|
if err == nil || !strings.Contains(err.Error(), "repo_host, repo_owner, repo_name are not unique") {
|
||||||
t.Errorf("Want unique constraint violated, got %s", err)
|
t.Errorf("Want unique constraint violated, got %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,11 @@ func testRepo(t *testing.T, repo *Repo) {
|
||||||
t.Errorf("Want Remote %v, got %v", want, got)
|
t.Errorf("Want Remote %v, got %v", want, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
got, want = repo.Host, "github.com"
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("Want Host %v, got %v", want, got)
|
||||||
|
}
|
||||||
|
|
||||||
got, want = repo.Owner, "lhofstadter"
|
got, want = repo.Owner, "lhofstadter"
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("Want Owner %v, got %v", want, got)
|
t.Errorf("Want Owner %v, got %v", want, got)
|
||||||
|
|
Loading…
Reference in a new issue