0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 11:42:52 +01:00

MySQL, Postgres integration tests in drone (#1638)

* MySQL, Postgres integration tests in drone

* Fix .drone.yml

* sign drone

* resign drone
This commit is contained in:
Ethan Koenig 2017-04-30 02:30:12 -04:00 committed by Bo-Yi Wu
parent 0308d44a16
commit 66c803fae2
9 changed files with 64 additions and 27 deletions

View file

@ -44,7 +44,7 @@ pipeline:
TAGS: bindata TAGS: bindata
GOPATH: /srv/app GOPATH: /srv/app
commands: commands:
- echo make test-mysql # Not ready yet - make test-mysql
when: when:
event: [ push, tag, pull_request ] event: [ push, tag, pull_request ]
@ -55,7 +55,7 @@ pipeline:
TAGS: bindata TAGS: bindata
GOPATH: /srv/app GOPATH: /srv/app
commands: commands:
- echo make test-pqsql # Not ready yet - make test-pgsql
when: when:
event: [ push, tag, pull_request ] event: [ push, tag, pull_request ]

View file

@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9zcnYvYXBwCiAgcGF0aDogc3JjL2NvZGUuZ2l0ZWEuaW8vZ2l0ZWEKCnBpcGVsaW5lOgogIGNsb25lOgogICAgaW1hZ2U6IHBsdWdpbnMvZ2l0CiAgICBkZXB0aDogNTAKICAgIHRhZ3M6IHRydWUKCiAgdGVzdDoKICAgIGltYWdlOiB3ZWJoaXBwaWUvZ29sYW5nOmVkZ2UKICAgIHB1bGw6IHRydWUKICAgIGVudmlyb25tZW50OgogICAgICBUQUdTOiBiaW5kYXRhIHNxbGl0ZQogICAgICBHT1BBVEg6IC9zcnYvYXBwCiAgICBjb21tYW5kczoKICAgICAgLSBhcGsgLVUgYWRkIG9wZW5zc2gtY2xpZW50CiAgICAgIC0gbWFrZSBjbGVhbgogICAgICAtIG1ha2UgZ2VuZXJhdGUKICAgICAgLSBtYWtlIHZldAogICAgICAtIG1ha2UgbGludAogICAgICAtIG1ha2UgdGVzdC12ZW5kb3IKICAgICAgLSBtYWtlIHRlc3Q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lcXVlc3QgXQo._gmaEu0hvh55_gmu1f06G5jdsDGIelMW0whjHfe7ovw

View file

@ -90,7 +90,6 @@ test-sqlite: integrations.test
.PHONY: test-mysql .PHONY: test-mysql
test-mysql: integrations.test test-mysql: integrations.test
echo "CREATE DATABASE IF NOT EXISTS testgitea" | mysql -u root
GITEA_CONF=integrations/mysql.ini ./integrations.test GITEA_CONF=integrations/mysql.ini ./integrations.test
.PHONY: test-pgsql .PHONY: test-pgsql

View file

@ -6,8 +6,10 @@ package integrations
import ( import (
"bytes" "bytes"
"database/sql"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"os" "os"
"testing" "testing"
@ -26,13 +28,7 @@ import (
var mac *macaron.Macaron var mac *macaron.Macaron
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
appIniPath := os.Getenv("GITEA_CONF") initIntegrationTest()
if appIniPath == "" {
fmt.Println("Environment variable $GITEA_CONF not set")
os.Exit(1)
}
setting.CustomConf = appIniPath
routers.GlobalInit()
mac = routes.NewMacaron() mac = routes.NewMacaron()
routes.RegisterRoutes(mac) routes.RegisterRoutes(mac)
@ -59,6 +55,48 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
func initIntegrationTest() {
if setting.CustomConf = os.Getenv("GITEA_CONF"); setting.CustomConf == "" {
fmt.Println("Environment variable $GITEA_CONF not set")
os.Exit(1)
}
setting.NewContext()
models.LoadConfigs()
switch {
case setting.UseMySQL:
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/",
models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host))
defer db.Close()
if err != nil {
log.Fatalf("sql.Open: %v", err)
}
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
}
case setting.UsePostgreSQL:
db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s",
models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host, models.DbCfg.SSLMode))
defer db.Close()
if err != nil {
log.Fatalf("sql.Open: %v", err)
}
rows, err := db.Query(fmt.Sprintf("SELECT 1 FROM pg_database WHERE datname = '%s'",
models.DbCfg.Name))
if err != nil {
log.Fatalf("db.Query: %v", err)
}
if rows.Next() {
break // database already exists
}
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
}
}
routers.GlobalInit()
}
func prepareTestEnv(t *testing.T) { func prepareTestEnv(t *testing.T) {
assert.NoError(t, models.LoadFixtures()) assert.NoError(t, models.LoadFixtures())
assert.NoError(t, os.RemoveAll("integrations/gitea-integration")) assert.NoError(t, os.RemoveAll("integrations/gitea-integration"))

View file

@ -42,14 +42,14 @@ ENABLE_FEDERATED_AVATAR = false
PROVIDER = file PROVIDER = file
[log] [log]
MODE = console,file MODE = console,file
ROOT_PATH = mysql-log
[log.console] [log.console]
LEVEL = Warn LEVEL = Warn
[log.file] [log.file]
LEVEL = Info LEVEL = Info
ROOT_PATH = log
[security] [security]
INSTALL_LOCK = true INSTALL_LOCK = true

View file

@ -43,13 +43,13 @@ PROVIDER = file
[log] [log]
MODE = console,file MODE = console,file
ROOT_PATH = pgsql-log
[log.console] [log.console]
LEVEL = Warn LEVEL = Warn
[log.file] [log.file]
LEVEL = Info LEVEL = Info
ROOT_PATH = log
[security] [security]
INSTALL_LOCK = true INSTALL_LOCK = true

View file

@ -13,7 +13,7 @@ import (
func TestIncreaseDownloadCount(t *testing.T) { func TestIncreaseDownloadCount(t *testing.T) {
assert.NoError(t, PrepareTestDatabase()) assert.NoError(t, PrepareTestDatabase())
attachment, err := GetAttachmentByUUID("1234567890") attachment, err := GetAttachmentByUUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, int64(0), attachment.DownloadCount) assert.Equal(t, int64(0), attachment.DownloadCount)
@ -21,7 +21,7 @@ func TestIncreaseDownloadCount(t *testing.T) {
err = attachment.IncreaseDownloadCount() err = attachment.IncreaseDownloadCount()
assert.NoError(t, err) assert.NoError(t, err)
attachment, err = GetAttachmentByUUID("1234567890") attachment, err = GetAttachmentByUUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, int64(1), attachment.DownloadCount) assert.Equal(t, int64(1), attachment.DownloadCount)
} }
@ -53,7 +53,7 @@ func TestDeleteAttachments(t *testing.T) {
err = DeleteAttachment(&Attachment{ID: 8}, false) err = DeleteAttachment(&Attachment{ID: 8}, false)
assert.NoError(t, err) assert.NoError(t, err)
attachment, err := GetAttachmentByUUID("test-12345") attachment, err := GetAttachmentByUUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18")
assert.Error(t, err) assert.Error(t, err)
assert.True(t, IsErrAttachmentNotExist(err)) assert.True(t, IsErrAttachmentNotExist(err))
assert.Nil(t, attachment) assert.Nil(t, attachment)

View file

@ -1,6 +1,6 @@
- -
id: 1 id: 1
uuid: 1234567890 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
issue_id: 1 issue_id: 1
comment_id: 0 comment_id: 0
name: attach1 name: attach1
@ -9,7 +9,7 @@
- -
id: 2 id: 2
uuid: 1122334455 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12
issue_id: 1 issue_id: 1
comment_id: 0 comment_id: 0
name: attach2 name: attach2
@ -18,7 +18,7 @@
- -
id: 3 id: 3
uuid: comment-id-1 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a13
issue_id: 2 issue_id: 2
comment_id: 1 comment_id: 1
name: attach1 name: attach1
@ -27,7 +27,7 @@
- -
id: 4 id: 4
uuid: comment-id-2 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14
issue_id: 3 issue_id: 3
comment_id: 1 comment_id: 1
name: attach2 name: attach2
@ -36,7 +36,7 @@
- -
id: 5 id: 5
uuid: comment-id-3 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a15
issue_id: 4 issue_id: 4
comment_id: 0 comment_id: 0
name: attach1 name: attach1
@ -45,7 +45,7 @@
- -
id: 6 id: 6
uuid: comment-id-4 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a16
issue_id: 5 issue_id: 5
comment_id: 2 comment_id: 2
name: attach1 name: attach1
@ -54,7 +54,7 @@
- -
id: 7 id: 7
uuid: comment-id-5 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17
issue_id: 5 issue_id: 5
comment_id: 2 comment_id: 2
name: attach1 name: attach1
@ -63,7 +63,7 @@
- -
id: 8 id: 8
uuid: test-12345 uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18
issue_id: 6 issue_id: 6
comment_id: 0 comment_id: 0
name: attach1 name: attach1

View file

@ -16,7 +16,7 @@
- -
id: 2 id: 2
type: 0 # gitea pull request type: 0 # gitea pull request
status: 1 # checking status: 2 # mergable
issue_id: 3 issue_id: 3
index: 3 index: 3
head_repo_id: 1 head_repo_id: 1