Use akyoto/assert for tests

This commit is contained in:
2019-08-25 15:41:59 +09:00
parent 8ff4e010fb
commit 3d89d2787a
12 changed files with 54 additions and 63 deletions

View File

@ -3,8 +3,8 @@ package arn_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn"
"github.com/stretchr/testify/assert"
)
func TestAnimeSort(t *testing.T) {

View File

@ -3,28 +3,28 @@ package arn_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn"
"github.com/stretchr/testify/assert"
)
func TestNewAnime(t *testing.T) {
anime := arn.NewAnime()
assert.NotNil(t, anime)
assert.NotEmpty(t, anime.ID)
assert.NotEmpty(t, anime.Created)
assert.NotEqual(t, anime.ID, "")
assert.NotEqual(t, anime.Created, "")
}
func TestGetAnime(t *testing.T) {
// Existing anime
anime, err := arn.GetAnime("74y2cFiiR")
assert.NoError(t, err)
assert.Nil(t, err)
assert.NotNil(t, anime)
assert.NotEmpty(t, anime.ID)
assert.NotEmpty(t, anime.Title.Canonical)
assert.NotEqual(t, anime.ID, "")
assert.NotEqual(t, anime.Title.Canonical, "")
// Not existing anime
anime, err = arn.GetAnime("does not exist")
assert.Error(t, err)
assert.NotNil(t, err)
assert.Nil(t, anime)
}
@ -49,14 +49,14 @@ func TestAllAnime(t *testing.T) {
for _, anime := range allAnime {
assert.NotEmpty(t, anime.ID)
assert.Contains(t, validAnimeStatus, anime.Status, "[%s] %s", anime.ID, anime.String())
assert.Contains(t, validAnimeType, anime.Type, "[%s] %s", anime.ID, anime.String())
assert.Contains(t, validAnimeStatus, anime.CalculatedStatus(), "[%s] %s", anime.ID, anime.String())
assert.NotEmpty(t, anime.StatusHumanReadable(), "[%s] %s", anime.ID, anime.String())
assert.NotEmpty(t, anime.TypeHumanReadable(), "[%s] %s", anime.ID, anime.String())
assert.NotEmpty(t, anime.Link(), "[%s] %s", anime.ID, anime.String())
assert.NotEmpty(t, anime.EpisodeCountString(), "[%s] %s", anime.ID, anime.String())
assert.NotEqual(t, anime.ID, "")
assert.Contains(t, validAnimeStatus, anime.Status)
assert.Contains(t, validAnimeType, anime.Type)
assert.Contains(t, validAnimeStatus, anime.CalculatedStatus())
assert.NotEqual(t, anime.StatusHumanReadable(), "")
assert.NotEqual(t, anime.TypeHumanReadable(), "")
assert.NotEqual(t, anime.Link(), "")
assert.NotEqual(t, anime.EpisodeCountString(), "")
anime.Episodes()
anime.Characters()

View File

@ -3,10 +3,10 @@ package arn_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn"
"github.com/stretchr/testify/assert"
)
func TestConnect(t *testing.T) {
assert.NotEmpty(t, arn.DB.Node().Address().String())
assert.NotEqual(t, arn.DB.Node().Address().String(), "")
}

View File

@ -3,18 +3,17 @@ package arn_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn"
)
func TestInventory(t *testing.T) {
inventory := arn.NewInventory("4J6qpK1ve")
assert.Len(t, inventory.Slots, arn.DefaultInventorySlotCount)
assert.Equal(t, len(inventory.Slots), arn.DefaultInventorySlotCount)
assert.False(t, inventory.ContainsItem("pro-account-3"))
err := inventory.AddItem("pro-account-3", 1)
assert.NoError(t, err)
assert.Nil(t, err)
assert.True(t, inventory.ContainsItem("pro-account-3"))
}

View File

@ -1,18 +1,17 @@
package arn_test
import (
"strings"
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn"
"github.com/stretchr/testify/assert"
)
func TestNewUser(t *testing.T) {
user := arn.NewUser()
assert.NotNil(t, user)
assert.NotEmpty(t, user.ID)
assert.NotEqual(t, user.ID, "")
}
func TestDatabaseErrorMessages(t *testing.T) {
@ -20,6 +19,5 @@ func TestDatabaseErrorMessages(t *testing.T) {
// We need to make sure that non-existent records return "not found" in the error message.
assert.NotNil(t, err)
assert.NotEmpty(t, err.Error())
assert.NotEqual(t, -1, strings.Index(err.Error(), "not found"))
assert.Contains(t, err.Error(), "not found")
}

View File

@ -3,8 +3,8 @@ package autocorrect_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn/autocorrect"
"github.com/stretchr/testify/assert"
)
func TestFixUserNick(t *testing.T) {

View File

@ -3,8 +3,8 @@ package search_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn/search"
"github.com/stretchr/testify/assert"
)
// Run these search terms and expect the
@ -39,8 +39,8 @@ var tests = map[string]string{
func TestAnimeSearch(t *testing.T) {
for term, expectedAnimeID := range tests {
results := search.Anime(term, 1)
assert.Len(t, results, 1, "%s -> %s", term, expectedAnimeID)
assert.Equal(t, expectedAnimeID, results[0].ID, "%s -> %s", term, expectedAnimeID)
assert.Equal(t, len(results), 1)
assert.Equal(t, expectedAnimeID, results[0].ID)
}
}

View File

@ -3,8 +3,8 @@ package stringutils_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn/stringutils"
"github.com/stretchr/testify/assert"
)
func TestRemoveSpecialCharacters(t *testing.T) {

View File

@ -3,8 +3,8 @@ package validate_test
import (
"testing"
"github.com/akyoto/assert"
"github.com/animenotifier/notify.moe/arn/validate"
"github.com/stretchr/testify/assert"
)
func TestIsValidNick(t *testing.T) {