mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-07-07 00:39:05 +07:00
Linter fix
This commit is contained in:
22
api_test.go
22
api_test.go
@ -11,6 +11,20 @@ import (
|
|||||||
|
|
||||||
func setupIris(t *testing.T, debug bool, noauth bool) *httpexpect.Expect {
|
func setupIris(t *testing.T, debug bool, noauth bool) *httpexpect.Expect {
|
||||||
iris.ResetDefault()
|
iris.ResetDefault()
|
||||||
|
var dbcfg = dbsettings{
|
||||||
|
Engine: "sqlite3",
|
||||||
|
Connection: ":memory:"}
|
||||||
|
var httpapicfg = httpapi{
|
||||||
|
Domain: "",
|
||||||
|
Port: "8080",
|
||||||
|
TLS: "none",
|
||||||
|
CorsOrigins: []string{"*"},
|
||||||
|
}
|
||||||
|
var dnscfg = DNSConfig{
|
||||||
|
API: httpapicfg,
|
||||||
|
Database: dbcfg,
|
||||||
|
}
|
||||||
|
DNSConf = dnscfg
|
||||||
var ForceAuth = authMiddleware{}
|
var ForceAuth = authMiddleware{}
|
||||||
iris.Get("/register", webRegisterGet)
|
iris.Get("/register", webRegisterGet)
|
||||||
iris.Post("/register", webRegisterPost)
|
iris.Post("/register", webRegisterPost)
|
||||||
@ -46,7 +60,7 @@ func TestApiRegister(t *testing.T) {
|
|||||||
|
|
||||||
func TestApiRegisterWithMockDB(t *testing.T) {
|
func TestApiRegisterWithMockDB(t *testing.T) {
|
||||||
e := setupIris(t, false, false)
|
e := setupIris(t, false, false)
|
||||||
old_db := DB.DB
|
oldDb := DB.DB
|
||||||
db, mock, _ := sqlmock.New()
|
db, mock, _ := sqlmock.New()
|
||||||
DB.DB = db
|
DB.DB = db
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
@ -56,7 +70,7 @@ func TestApiRegisterWithMockDB(t *testing.T) {
|
|||||||
Status(iris.StatusInternalServerError).
|
Status(iris.StatusInternalServerError).
|
||||||
JSON().Object().
|
JSON().Object().
|
||||||
ContainsKey("error")
|
ContainsKey("error")
|
||||||
DB.DB = old_db
|
DB.DB = oldDb
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApiUpdateWithoutCredentials(t *testing.T) {
|
func TestApiUpdateWithoutCredentials(t *testing.T) {
|
||||||
@ -107,7 +121,7 @@ func TestApiUpdateWithCredentialsMockDB(t *testing.T) {
|
|||||||
updateJSON["txt"] = validTxtData
|
updateJSON["txt"] = validTxtData
|
||||||
|
|
||||||
e := setupIris(t, false, true)
|
e := setupIris(t, false, true)
|
||||||
old_db := DB.DB
|
oldDb := DB.DB
|
||||||
db, mock, _ := sqlmock.New()
|
db, mock, _ := sqlmock.New()
|
||||||
DB.DB = db
|
DB.DB = db
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
@ -119,7 +133,7 @@ func TestApiUpdateWithCredentialsMockDB(t *testing.T) {
|
|||||||
Status(iris.StatusInternalServerError).
|
Status(iris.StatusInternalServerError).
|
||||||
JSON().Object().
|
JSON().Object().
|
||||||
ContainsKey("error")
|
ContainsKey("error")
|
||||||
DB.DB = old_db
|
DB.DB = oldDb
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApiManyUpdateWithCredentials(t *testing.T) {
|
func TestApiManyUpdateWithCredentials(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user