Add additional tests

Signed-off-by: Jonas Franz <info@jonasfranz.software>
web-ui
Jonas Franz 6 years ago
parent 1553720ab9
commit e913bbea86
Signed by untrusted user: JonasFranzDEV
GPG Key ID: 506AEEBE80BEDECD
  1. 16
      migrations/github_test.go
  2. 4
      migrations/issue_test.go
  3. 11
      migrations/utils.go

@ -13,12 +13,28 @@ func BenchmarkGetIssueIndexFromHTMLURLAlt(b *testing.B) {
}
}
func TestGetIssueIndexFromHTMLURLAlt(t *testing.T) {
res, err := getIssueIndexFromHTMLURLAlt("https://github.com/octocat/Hello-World/issues/1347#issuecomment-1")
assert.NoError(t, err)
assert.Equal(t, 1347, res)
res, err = getIssueIndexFromHTMLURLAlt("https://github.com/oment-1")
assert.Error(t, err)
}
func BenchmarkGetIssueIndexFromHTMLURL(b *testing.B) {
for i := 0; i <= b.N; i++ {
getIssueIndexFromHTMLURL("https://github.com/octocat/Hello-World/issues/1347#issuecomment-1")
}
}
func TestGetIssueIndexFromHTMLURL(t *testing.T) {
res, err := getIssueIndexFromHTMLURL("https://github.com/octocat/Hello-World/issues/1347#issuecomment-1")
assert.NoError(t, err)
assert.Equal(t, 1347, res)
res, err = getIssueIndexFromHTMLURL("https://github.com/oment-1")
assert.Error(t, err)
}
var testFMig = &FetchMigratory{
Migratory: *DemoMigratory,
GHClient: github.NewClient(nil),

@ -28,7 +28,7 @@ func TestMigratory_Label(t *testing.T) {
Name: github.String("testlabel"),
Color: github.String("123456"),
})
assert.NoError(t, err)
assertNoError(t, err)
assert.Equal(t, "123456", res.Color)
assert.Equal(t, "testlabel", res.Name)
}
@ -41,7 +41,7 @@ func TestMigratory_Milestone(t *testing.T) {
Title: github.String("TEST"),
DueOn: &demoTime,
})
assert.NoError(t, err)
assertNoError(t, err)
assert.Equal(t, "TEST", res.Title)
assert.Equal(t, "test milestone", res.Description)
assert.Equal(t, demoTime.Unix(), res.Deadline.Unix())

@ -1,9 +1,12 @@
package migrations
import (
"strings"
"testing"
"time"
"code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)
// DemoMigratory is been used for testing
@ -25,3 +28,11 @@ var DemoMigratory = &Migratory{
}
var demoTime = time.Date(2018, 01, 01, 01, 01, 01, 01, time.UTC)
func assertNoError(t *testing.T, err error) {
if strings.Contains(err.Error(), "lookup gitea") {
t.Skip("gitea instance is not running")
} else {
assert.NoError(t, err)
}
}

Loading…
Cancel
Save