mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-07 00:23:17 -06:00
some more fiddling
This commit is contained in:
parent
6f2cb1b9ad
commit
c0fc8cf9e9
2 changed files with 22 additions and 46 deletions
21
.drone.yml
21
.drone.yml
|
|
@ -1,23 +1,36 @@
|
|||
### Drone configuration file for GoToSocial.
|
||||
### Connects to https://drone.superseriousbusiness.org to perform testing, linting, and automatic builds/pushes to docker.
|
||||
###
|
||||
### For documentation on drone, see: https://docs.drone.io/
|
||||
### For documentation on drone docker pipelines in particular: https://docs.drone.io/pipeline/docker/overview/
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
steps:
|
||||
|
||||
# We use golangci-lint for linting.
|
||||
# See: https://golangci-lint.run/
|
||||
- name: lint
|
||||
image: golangci/golangci-lint:v1.41.1
|
||||
commands:
|
||||
- golangci-lint run --timeout 5m0s --tests=false
|
||||
|
||||
- name: test
|
||||
image: golang
|
||||
image: golang:1.16.4-alpine3.13
|
||||
environment:
|
||||
GTS_DB_ADDRESS: postgres
|
||||
commands:
|
||||
# `-count 1` => run all tests at least once
|
||||
# `-p 1` => run maximum one test at a time
|
||||
# `./...` => run all tests
|
||||
- go test -count 1 -p 1 ./...
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
username:
|
||||
from_secret: gts_docker_username
|
||||
username: gotosocial
|
||||
password:
|
||||
from_secret: gts_docker_password
|
||||
repo: superseriousbusiness/gotosocial
|
||||
|
|
@ -28,6 +41,8 @@ steps:
|
|||
- pull_request
|
||||
|
||||
services:
|
||||
# We need this postgres service running for the test step.
|
||||
# See: https://docs.drone.io/pipeline/docker/syntax/services/
|
||||
- name: postgres
|
||||
image: postgres
|
||||
environment:
|
||||
|
|
|
|||
|
|
@ -21,12 +21,10 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db/pg"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
"github.com/superseriousbusiness/oauth2/v4/models"
|
||||
)
|
||||
|
||||
|
|
@ -51,50 +49,13 @@ func (suite *PgClientStoreTestSuite) SetupSuite() {
|
|||
|
||||
// SetupTest creates a postgres connection and creates the oauth_clients table before each test
|
||||
func (suite *PgClientStoreTestSuite) SetupTest() {
|
||||
log := logrus.New()
|
||||
log.SetLevel(logrus.TraceLevel)
|
||||
c := config.Empty()
|
||||
c.DBConfig = &config.DBConfig{
|
||||
Type: "postgres",
|
||||
Address: "localhost",
|
||||
Port: 5432,
|
||||
User: "postgres",
|
||||
Password: "postgres",
|
||||
Database: "postgres",
|
||||
ApplicationName: "gotosocial",
|
||||
}
|
||||
db, err := pg.NewPostgresService(context.Background(), c, log)
|
||||
if err != nil {
|
||||
logrus.Panicf("error creating database connection: %s", err)
|
||||
}
|
||||
|
||||
suite.db = db
|
||||
|
||||
models := []interface{}{
|
||||
&oauth.Client{},
|
||||
}
|
||||
|
||||
for _, m := range models {
|
||||
if err := suite.db.CreateTable(m); err != nil {
|
||||
logrus.Panicf("db connection error: %s", err)
|
||||
}
|
||||
}
|
||||
suite.db = testrig.NewTestDB()
|
||||
testrig.StandardDBSetup(suite.db, nil)
|
||||
}
|
||||
|
||||
// TearDownTest drops the oauth_clients table and closes the pg connection after each test
|
||||
func (suite *PgClientStoreTestSuite) TearDownTest() {
|
||||
models := []interface{}{
|
||||
&oauth.Client{},
|
||||
}
|
||||
for _, m := range models {
|
||||
if err := suite.db.DropTable(m); err != nil {
|
||||
logrus.Panicf("error dropping table: %s", err)
|
||||
}
|
||||
}
|
||||
if err := suite.db.Stop(context.Background()); err != nil {
|
||||
logrus.Panicf("error closing db connection: %s", err)
|
||||
}
|
||||
suite.db = nil
|
||||
testrig.StandardDBTeardown(suite.db)
|
||||
}
|
||||
|
||||
func (suite *PgClientStoreTestSuite) TestClientStoreSetAndGet() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue