From 846b600d95ce1a2e9bdc16b7f24e8f8052eb0093 Mon Sep 17 00:00:00 2001 From: Naoki Kosaka Date: Mon, 21 Jun 2021 07:37:42 +0900 Subject: [PATCH] Move test resource to misc/test. --- api/api_test.go | 4 ++-- api/decode_test.go | 8 ++++---- api/handle_test.go | 18 +++++++++--------- control/config_test.go | 6 +++--- control/control_test.go | 4 ++-- control/domain_test.go | 16 ++++++++-------- control/follow_test.go | 2 +- deliver/deriver_test.go | 4 ++-- misc/{ => test}/announce.json | 0 misc/{ => test}/application.json | 0 misc/{ => test}/blankConfig.json | 0 misc/{ => test}/config.yml | 0 misc/{ => test}/create.json | 0 misc/{ => test}/exampleConfig.json | 0 misc/{ => test}/follow.json | 0 misc/{ => test}/followAsActor.json | 0 misc/{ => test}/person.json | 0 misc/{ => test}/service.json | 0 misc/{ => test}/testKey.pem | 0 misc/{ => test}/undo.json | 0 misc/{ => test}/unfollow.json | 0 models/models_test.go | 4 ++-- 22 files changed, 33 insertions(+), 33 deletions(-) rename misc/{ => test}/announce.json (100%) rename misc/{ => test}/application.json (100%) rename misc/{ => test}/blankConfig.json (100%) rename misc/{ => test}/config.yml (100%) rename misc/{ => test}/create.json (100%) rename misc/{ => test}/exampleConfig.json (100%) rename misc/{ => test}/follow.json (100%) rename misc/{ => test}/followAsActor.json (100%) rename misc/{ => test}/person.json (100%) rename misc/{ => test}/service.json (100%) rename misc/{ => test}/testKey.pem (100%) rename misc/{ => test}/undo.json (100%) rename misc/{ => test}/unfollow.json (100%) diff --git a/api/api_test.go b/api/api_test.go index b22e574..1f129c8 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -12,13 +12,13 @@ import ( func TestMain(m *testing.M) { var err error - testConfigPath := "../misc/config.yml" + testConfigPath := "../misc/test/config.yml" file, _ := os.Open(testConfigPath) defer file.Close() viper.SetConfigType("yaml") viper.ReadConfig(file) - viper.Set("ACTOR_PEM", "../misc/testKey.pem") + viper.Set("ACTOR_PEM", "../misc/test/testKey.pem") viper.BindEnv("REDIS_URL") globalConfig, err = models.NewRelayConfig() diff --git a/api/decode_test.go b/api/decode_test.go index 7782164..a0be430 100644 --- a/api/decode_test.go +++ b/api/decode_test.go @@ -20,7 +20,7 @@ func TestDecodeActivity(t *testing.T) { InboxURL: "https://innocent.yukimochi.io/inbox", }) - file, _ := os.Open("../misc/create.json") + file, _ := os.Open("../misc/test/create.json") body, _ := ioutil.ReadAll(file) length := strconv.Itoa(len(body)) req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body)) @@ -50,7 +50,7 @@ func TestDecodeActivityWithNoSignature(t *testing.T) { InboxURL: "https://innocent.yukimochi.io/inbox", }) - file, _ := os.Open("../misc/create.json") + file, _ := os.Open("../misc/test/create.json") body, _ := ioutil.ReadAll(file) length := strconv.Itoa(len(body)) req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body)) @@ -74,7 +74,7 @@ func TestDecodeActivityWithNotFoundKeyId(t *testing.T) { InboxURL: "https://innocent.yukimochi.io/inbox", }) - file, _ := os.Open("../misc/create.json") + file, _ := os.Open("../misc/test/create.json") body, _ := ioutil.ReadAll(file) length := strconv.Itoa(len(body)) req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body)) @@ -99,7 +99,7 @@ func TestDecodeActivityWithInvalidDigest(t *testing.T) { InboxURL: "https://innocent.yukimochi.io/inbox", }) - file, _ := os.Open("../misc/create.json") + file, _ := os.Open("../misc/test/create.json") body, _ := ioutil.ReadAll(file) length := strconv.Itoa(len(body)) req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body)) diff --git a/api/handle_test.go b/api/handle_test.go index da57df5..b32ba1a 100644 --- a/api/handle_test.go +++ b/api/handle_test.go @@ -254,19 +254,19 @@ func mockActivityDecoderProvider(activity *models.Activity, actor *models.Actor) func mockActivity(req string) models.Activity { switch req { case "Follow": - file, _ := os.Open("../misc/follow.json") + file, _ := os.Open("../misc/test/follow.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) return activity case "Invalid-Follow": - file, _ := os.Open("../misc/followAsActor.json") + file, _ := os.Open("../misc/test/followAsActor.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) return activity case "Unfollow": - file, _ := os.Open("../misc/unfollow.json") + file, _ := os.Open("../misc/test/unfollow.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) @@ -282,7 +282,7 @@ func mockActivity(req string) models.Activity { json.Unmarshal([]byte(body), &activity) return activity case "Create": - file, _ := os.Open("../misc/create.json") + file, _ := os.Open("../misc/test/create.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) @@ -293,13 +293,13 @@ func mockActivity(req string) models.Activity { json.Unmarshal([]byte(body), &activity) return activity case "Announce": - file, _ := os.Open("../misc/announce.json") + file, _ := os.Open("../misc/test/announce.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) return activity case "Undo": - file, _ := os.Open("../misc/undo.json") + file, _ := os.Open("../misc/test/undo.json") body, _ := ioutil.ReadAll(file) var activity models.Activity json.Unmarshal(body, &activity) @@ -312,19 +312,19 @@ func mockActivity(req string) models.Activity { func mockActor(req string) models.Actor { switch req { case "Person": - file, _ := os.Open("../misc/person.json") + file, _ := os.Open("../misc/test/person.json") body, _ := ioutil.ReadAll(file) var actor models.Actor json.Unmarshal(body, &actor) return actor case "Service": - file, _ := os.Open("../misc/service.json") + file, _ := os.Open("../misc/test/service.json") body, _ := ioutil.ReadAll(file) var actor models.Actor json.Unmarshal(body, &actor) return actor case "Application": - file, _ := os.Open("../misc/application.json") + file, _ := os.Open("../misc/test/application.json") body, _ := ioutil.ReadAll(file) var actor models.Actor json.Unmarshal(body, &actor) diff --git a/control/config_test.go b/control/config_test.go index 77414ba..48f83e9 100644 --- a/control/config_test.go +++ b/control/config_test.go @@ -123,7 +123,7 @@ func TestExportConfig(t *testing.T) { app.SetArgs([]string{"export"}) app.Execute() - file, err := os.Open("../misc/blankConfig.json") + file, err := os.Open("../misc/test/blankConfig.json") if err != nil { t.Fatalf("Test resource fetch error.") } @@ -139,7 +139,7 @@ func TestImportConfig(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() @@ -149,7 +149,7 @@ func TestImportConfig(t *testing.T) { app.SetArgs([]string{"export"}) app.Execute() - file, err := os.Open("../misc/exampleConfig.json") + file, err := os.Open("../misc/test/exampleConfig.json") if err != nil { t.Fatalf("Test resource fetch error.") } diff --git a/control/control_test.go b/control/control_test.go index 2b8d693..a8d4c22 100644 --- a/control/control_test.go +++ b/control/control_test.go @@ -13,13 +13,13 @@ import ( func TestMain(m *testing.M) { var err error - testConfigPath := "../misc/config.yml" + testConfigPath := "../misc/test/config.yml" file, _ := os.Open(testConfigPath) defer file.Close() viper.SetConfigType("yaml") viper.ReadConfig(file) - viper.Set("ACTOR_PEM", "../misc/testKey.pem") + viper.Set("ACTOR_PEM", "../misc/test/testKey.pem") viper.BindEnv("REDIS_URL") globalConfig, err = models.NewRelayConfig() diff --git a/control/domain_test.go b/control/domain_test.go index 6c7cf74..d0d302c 100644 --- a/control/domain_test.go +++ b/control/domain_test.go @@ -10,7 +10,7 @@ func TestListDomainSubscriber(t *testing.T) { relayState.RedisClient.FlushAll().Result() app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() @@ -36,7 +36,7 @@ func TestListDomainLimited(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() @@ -62,7 +62,7 @@ func TestListDomainBlocked(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() @@ -130,7 +130,7 @@ func TestUnsetDomainBlocked(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() app = domainCmdInit() @@ -155,7 +155,7 @@ func TestUnsetDomainLimited(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() app = domainCmdInit() @@ -180,7 +180,7 @@ func TestSetDomainInvalid(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() @@ -202,7 +202,7 @@ func TestUnfollowDomain(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() app = domainCmdInit() @@ -227,7 +227,7 @@ func TestInvalidUnfollowDomain(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() relayState.Load() diff --git a/control/follow_test.go b/control/follow_test.go index 47c3240..2d4365a 100644 --- a/control/follow_test.go +++ b/control/follow_test.go @@ -126,7 +126,7 @@ func TestInvalidRejectFollow(t *testing.T) { func TestCreateUpdateActorActivity(t *testing.T) { app := configCmdInit() - app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"}) + app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"}) app.Execute() app = followCmdInit() diff --git a/deliver/deriver_test.go b/deliver/deriver_test.go index eb4708c..56eb13b 100644 --- a/deliver/deriver_test.go +++ b/deliver/deriver_test.go @@ -16,13 +16,13 @@ import ( func TestMain(m *testing.M) { var err error - testConfigPath := "../misc/config.yml" + testConfigPath := "../misc/test/config.yml" file, _ := os.Open(testConfigPath) defer file.Close() viper.SetConfigType("yaml") viper.ReadConfig(file) - viper.Set("ACTOR_PEM", "../misc/testKey.pem") + viper.Set("ACTOR_PEM", "../misc/test/testKey.pem") viper.BindEnv("REDIS_URL") globalConfig, err = models.NewRelayConfig() diff --git a/misc/announce.json b/misc/test/announce.json similarity index 100% rename from misc/announce.json rename to misc/test/announce.json diff --git a/misc/application.json b/misc/test/application.json similarity index 100% rename from misc/application.json rename to misc/test/application.json diff --git a/misc/blankConfig.json b/misc/test/blankConfig.json similarity index 100% rename from misc/blankConfig.json rename to misc/test/blankConfig.json diff --git a/misc/config.yml b/misc/test/config.yml similarity index 100% rename from misc/config.yml rename to misc/test/config.yml diff --git a/misc/create.json b/misc/test/create.json similarity index 100% rename from misc/create.json rename to misc/test/create.json diff --git a/misc/exampleConfig.json b/misc/test/exampleConfig.json similarity index 100% rename from misc/exampleConfig.json rename to misc/test/exampleConfig.json diff --git a/misc/follow.json b/misc/test/follow.json similarity index 100% rename from misc/follow.json rename to misc/test/follow.json diff --git a/misc/followAsActor.json b/misc/test/followAsActor.json similarity index 100% rename from misc/followAsActor.json rename to misc/test/followAsActor.json diff --git a/misc/person.json b/misc/test/person.json similarity index 100% rename from misc/person.json rename to misc/test/person.json diff --git a/misc/service.json b/misc/test/service.json similarity index 100% rename from misc/service.json rename to misc/test/service.json diff --git a/misc/testKey.pem b/misc/test/testKey.pem similarity index 100% rename from misc/testKey.pem rename to misc/test/testKey.pem diff --git a/misc/undo.json b/misc/test/undo.json similarity index 100% rename from misc/undo.json rename to misc/test/undo.json diff --git a/misc/unfollow.json b/misc/test/unfollow.json similarity index 100% rename from misc/unfollow.json rename to misc/test/unfollow.json diff --git a/models/models_test.go b/models/models_test.go index afa3571..d516233 100644 --- a/models/models_test.go +++ b/models/models_test.go @@ -15,13 +15,13 @@ var ch chan bool func TestMain(m *testing.M) { var err error - testConfigPath := "../misc/config.yml" + testConfigPath := "../misc/test/config.yml" file, _ := os.Open(testConfigPath) defer file.Close() viper.SetConfigType("yaml") viper.ReadConfig(file) - viper.Set("ACTOR_PEM", "../misc/testKey.pem") + viper.Set("ACTOR_PEM", "../misc/test/testKey.pem") viper.BindEnv("REDIS_URL") globalConfig, err = NewRelayConfig()