Improve state test.

This commit is contained in:
Naoki Kosaka
2020-01-02 01:26:43 +09:00
parent 1cdc820d6d
commit 9f439a0629
6 changed files with 170 additions and 128 deletions

View File

@ -5,14 +5,12 @@ import (
"testing"
"github.com/spf13/viper"
state "github.com/yukimochi/Activity-Relay/State"
)
func TestMain(m *testing.M) {
viper.Set("actor_pem", "../misc/testKey.pem")
viper.Set("relay_domain", "relay.yukimochi.example.org")
initConfig()
relayState = state.NewState(relayState.RedisClient, false)
relayState.RedisClient.FlushAll().Result()
code := m.Run()

View File

@ -24,6 +24,7 @@ func TestServiceBlock(t *testing.T) {
t.Fatalf("Not Disabled Blocking feature for service-type actor")
}
}
func TestManuallyAccept(t *testing.T) {
app := buildNewCmd()
@ -40,6 +41,7 @@ func TestManuallyAccept(t *testing.T) {
t.Fatalf("Not Disabled Manually accept follow-request feature")
}
}
func TestCreateAsAnnounce(t *testing.T) {
app := buildNewCmd()
@ -56,6 +58,7 @@ func TestCreateAsAnnounce(t *testing.T) {
t.Fatalf("Enable announce activity instead of relay create activity")
}
}
func TestInvalidConfig(t *testing.T) {
app := buildNewCmd()
buffer := new(bytes.Buffer)
@ -115,6 +118,7 @@ func TestExportConfig(t *testing.T) {
t.Fatalf("Invalid Responce.")
}
}
func TestImportConfig(t *testing.T) {
app := buildNewCmd()

View File

@ -121,9 +121,9 @@ func unfollowDomains(cmd *cobra.Command, args []string) error {
for _, domain := range args {
if contains(subscriptions, domain) {
subscription := *relayState.SelectSubscription(domain)
cmd.Println("Unfollow [" + subscription.Domain + "]")
createUnfollowRequestResponse(subscription)
relayState.DelSubscription(subscription.Domain)
cmd.Println("Unfollow [" + subscription.Domain + "]")
break
} else {
cmd.Println("Invalid domain [" + domain + "] given")