mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
Simple tests for Backend.FromConfig implementations
This commit is contained in:
parent
aa01ae1342
commit
c4ae2eda48
4 changed files with 61 additions and 0 deletions
|
@ -25,11 +25,19 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
||||||
"go.uploadedlobster.com/scotty/models"
|
"go.uploadedlobster.com/scotty/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestFromConfig(t *testing.T) {
|
||||||
|
config := viper.New()
|
||||||
|
config.Set("token", "thetoken")
|
||||||
|
backend := funkwhale.FunkwhaleApiBackend{}.FromConfig(config)
|
||||||
|
assert.IsType(t, funkwhale.FunkwhaleApiBackend{}, backend)
|
||||||
|
}
|
||||||
|
|
||||||
func TestFunkwhaleListeningToListen(t *testing.T) {
|
func TestFunkwhaleListeningToListen(t *testing.T) {
|
||||||
fwListen := funkwhale.Listening{
|
fwListen := funkwhale.Listening{
|
||||||
CreationDate: "2023-11-09T23:59:29.022005Z",
|
CreationDate: "2023-11-09T23:59:29.022005Z",
|
||||||
|
|
|
@ -25,11 +25,19 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||||
"go.uploadedlobster.com/scotty/models"
|
"go.uploadedlobster.com/scotty/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestFromConfig(t *testing.T) {
|
||||||
|
config := viper.New()
|
||||||
|
config.Set("token", "thetoken")
|
||||||
|
backend := listenbrainz.ListenBrainzApiBackend{}.FromConfig(config)
|
||||||
|
assert.IsType(t, listenbrainz.ListenBrainzApiBackend{}, backend)
|
||||||
|
}
|
||||||
|
|
||||||
func TestListenBrainzListenToListen(t *testing.T) {
|
func TestListenBrainzListenToListen(t *testing.T) {
|
||||||
lbListen := listenbrainz.Listen{
|
lbListen := listenbrainz.Listen{
|
||||||
ListenedAt: 1699289873,
|
ListenedAt: 1699289873,
|
||||||
|
|
|
@ -25,10 +25,18 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uploadedlobster.com/scotty/backends/maloja"
|
"go.uploadedlobster.com/scotty/backends/maloja"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestFromConfig(t *testing.T) {
|
||||||
|
config := viper.New()
|
||||||
|
config.Set("token", "thetoken")
|
||||||
|
backend := maloja.MalojaApiBackend{}.FromConfig(config)
|
||||||
|
assert.IsType(t, maloja.MalojaApiBackend{}, backend)
|
||||||
|
}
|
||||||
|
|
||||||
func TestScrobbleToListen(t *testing.T) {
|
func TestScrobbleToListen(t *testing.T) {
|
||||||
scrobble := maloja.Scrobble{
|
scrobble := maloja.Scrobble{
|
||||||
ListenedAt: 1699289873,
|
ListenedAt: 1699289873,
|
||||||
|
|
37
backends/scrobblerlog/scrobblerlog_test.go
Normal file
37
backends/scrobblerlog/scrobblerlog_test.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package scrobblerlog_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFromConfig(t *testing.T) {
|
||||||
|
config := viper.New()
|
||||||
|
config.Set("token", "thetoken")
|
||||||
|
backend := scrobblerlog.ScrobblerLogBackend{}.FromConfig(config)
|
||||||
|
assert.IsType(t, scrobblerlog.ScrobblerLogBackend{}, backend)
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue