Fix and reenable automatic tests

This commit is contained in:
Jan-Lukas Else 2022-07-17 07:35:39 +02:00
parent 208ac792cd
commit 0acfbd393b
29 changed files with 95 additions and 6 deletions

View File

@ -23,12 +23,12 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Test
# uses: docker/build-push-action@v2
# with:
# push: false
# target: test
# tags: test
- name: Test
uses: docker/build-push-action@v2
with:
push: false
target: test
tags: test
- name: Build base image
uses: docker/build-push-action@v2
with:

View File

@ -49,6 +49,9 @@ func Test_webfinger(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
app.cfg.Server.PublicAddress = "https://example.com"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

7
app_test.go Normal file
View File

@ -0,0 +1,7 @@
package main
func (a *goBlog) cleanup() {
if a.db != nil {
_ = a.db.close()
}
}

View File

@ -29,6 +29,8 @@ func Test_authMiddleware(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -35,6 +35,8 @@ func Test_blogroll(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -32,6 +32,8 @@ func Test_blogStats(t *testing.T) {
}
app.cfg.DefaultBlog = "en"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -23,6 +23,8 @@ func Test_captchaMiddleware(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -29,6 +29,8 @@ func Test_comments(t *testing.T) {
}
app.cfg.DefaultBlog = "en"
t.Cleanup(app.cleanup)
err := app.initConfig(false)
require.NoError(t, err)
app.initComponents(false)

View File

@ -43,6 +43,8 @@ func Test_contact(t *testing.T) {
}
app.cfg.DefaultBlog = "en"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -15,6 +15,9 @@ func Test_editorPreview(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -15,6 +15,8 @@ func Test_errors(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -15,6 +15,9 @@ func Test_feeds(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -21,6 +21,8 @@ func Test_geoTrack(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -17,6 +17,8 @@ func Test_geo(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -20,6 +20,8 @@ func Test_indexNow(t *testing.T) {
}
app.cfg.IndexNow = &configIndexNow{Enabled: true}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -35,6 +35,8 @@ func Test_indieAuthServer(t *testing.T) {
}
app.cfg.Cache.Enable = false
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -17,6 +17,8 @@ func Test_checkIndieAuth(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -14,6 +14,9 @@ func Test_micropubQuery(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -18,6 +18,8 @@ func Test_ntfySending(t *testing.T) {
httpClient: fakeClient.Client,
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -24,6 +24,9 @@ func Test_postsDb(t *testing.T) {
},
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -380,6 +383,9 @@ func Test_postDeletesParams(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -12,6 +12,8 @@ func Test_checkDeletedPosts(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -22,6 +22,8 @@ func Test_postsScheduler(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -16,6 +16,9 @@ func Test_serveDate(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -104,6 +107,9 @@ func Test_servePost(t *testing.T) {
Username: "test",
Password: "test",
})
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -36,6 +36,8 @@ func Test_privateMode(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -15,6 +15,9 @@ func Test_reactionsLowLevel(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -95,6 +98,9 @@ func Test_reactionsHighLevel(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -17,6 +17,8 @@ func Test_sitemap(t *testing.T) {
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -20,6 +20,9 @@ func Test_renderPostTax(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -46,6 +49,9 @@ func Test_renderOldContentWarning(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -73,6 +79,8 @@ func Test_renderInteractions(t *testing.T) {
}
app.cfg.Server.PublicAddress = "https://example.com"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -142,6 +150,8 @@ func Test_renderAuthor(t *testing.T) {
app.cfg.User.Picture = "https://example.com/picture.jpg"
app.cfg.User.Name = "John Doe"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -29,6 +29,8 @@ func Test_verifyMention(t *testing.T) {
}
app.cfg.Server.PublicAddress = "https://example.org"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -70,6 +72,8 @@ func Test_verifyMentionBidgy(t *testing.T) {
}
app.cfg.Server.PublicAddress = "https://example.org"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)
@ -107,6 +111,8 @@ func Test_verifyMentionColin(t *testing.T) {
}
app.cfg.Server.PublicAddress = "https://jlelse.blog"
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)

View File

@ -19,6 +19,8 @@ func Test_webmentions(t *testing.T) {
},
}
t.Cleanup(app.cleanup)
_ = app.initConfig(false)
app.initComponents(false)