Move test resource to misc/test.

This commit is contained in:
Naoki Kosaka 2021-06-21 07:37:42 +09:00
parent 1260985b75
commit 846b600d95
22 changed files with 33 additions and 33 deletions

View File

@ -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()

View File

@ -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))

View File

@ -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)

View File

@ -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.")
}

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()