Move test resource to misc/test.
This commit is contained in:
parent
1260985b75
commit
846b600d95
@ -12,13 +12,13 @@ import (
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testConfigPath := "../misc/config.yml"
|
testConfigPath := "../misc/test/config.yml"
|
||||||
file, _ := os.Open(testConfigPath)
|
file, _ := os.Open(testConfigPath)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.ReadConfig(file)
|
viper.ReadConfig(file)
|
||||||
viper.Set("ACTOR_PEM", "../misc/testKey.pem")
|
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||||
viper.BindEnv("REDIS_URL")
|
viper.BindEnv("REDIS_URL")
|
||||||
|
|
||||||
globalConfig, err = models.NewRelayConfig()
|
globalConfig, err = models.NewRelayConfig()
|
||||||
|
@ -20,7 +20,7 @@ func TestDecodeActivity(t *testing.T) {
|
|||||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||||
})
|
})
|
||||||
|
|
||||||
file, _ := os.Open("../misc/create.json")
|
file, _ := os.Open("../misc/test/create.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
length := strconv.Itoa(len(body))
|
length := strconv.Itoa(len(body))
|
||||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||||
@ -50,7 +50,7 @@ func TestDecodeActivityWithNoSignature(t *testing.T) {
|
|||||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||||
})
|
})
|
||||||
|
|
||||||
file, _ := os.Open("../misc/create.json")
|
file, _ := os.Open("../misc/test/create.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
length := strconv.Itoa(len(body))
|
length := strconv.Itoa(len(body))
|
||||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||||
@ -74,7 +74,7 @@ func TestDecodeActivityWithNotFoundKeyId(t *testing.T) {
|
|||||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||||
})
|
})
|
||||||
|
|
||||||
file, _ := os.Open("../misc/create.json")
|
file, _ := os.Open("../misc/test/create.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
length := strconv.Itoa(len(body))
|
length := strconv.Itoa(len(body))
|
||||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||||
@ -99,7 +99,7 @@ func TestDecodeActivityWithInvalidDigest(t *testing.T) {
|
|||||||
InboxURL: "https://innocent.yukimochi.io/inbox",
|
InboxURL: "https://innocent.yukimochi.io/inbox",
|
||||||
})
|
})
|
||||||
|
|
||||||
file, _ := os.Open("../misc/create.json")
|
file, _ := os.Open("../misc/test/create.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
length := strconv.Itoa(len(body))
|
length := strconv.Itoa(len(body))
|
||||||
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
req, _ := http.NewRequest("POST", "/inbox", bytes.NewReader(body))
|
||||||
|
@ -254,19 +254,19 @@ func mockActivityDecoderProvider(activity *models.Activity, actor *models.Actor)
|
|||||||
func mockActivity(req string) models.Activity {
|
func mockActivity(req string) models.Activity {
|
||||||
switch req {
|
switch req {
|
||||||
case "Follow":
|
case "Follow":
|
||||||
file, _ := os.Open("../misc/follow.json")
|
file, _ := os.Open("../misc/test/follow.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
return activity
|
return activity
|
||||||
case "Invalid-Follow":
|
case "Invalid-Follow":
|
||||||
file, _ := os.Open("../misc/followAsActor.json")
|
file, _ := os.Open("../misc/test/followAsActor.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
return activity
|
return activity
|
||||||
case "Unfollow":
|
case "Unfollow":
|
||||||
file, _ := os.Open("../misc/unfollow.json")
|
file, _ := os.Open("../misc/test/unfollow.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
@ -282,7 +282,7 @@ func mockActivity(req string) models.Activity {
|
|||||||
json.Unmarshal([]byte(body), &activity)
|
json.Unmarshal([]byte(body), &activity)
|
||||||
return activity
|
return activity
|
||||||
case "Create":
|
case "Create":
|
||||||
file, _ := os.Open("../misc/create.json")
|
file, _ := os.Open("../misc/test/create.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
@ -293,13 +293,13 @@ func mockActivity(req string) models.Activity {
|
|||||||
json.Unmarshal([]byte(body), &activity)
|
json.Unmarshal([]byte(body), &activity)
|
||||||
return activity
|
return activity
|
||||||
case "Announce":
|
case "Announce":
|
||||||
file, _ := os.Open("../misc/announce.json")
|
file, _ := os.Open("../misc/test/announce.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
return activity
|
return activity
|
||||||
case "Undo":
|
case "Undo":
|
||||||
file, _ := os.Open("../misc/undo.json")
|
file, _ := os.Open("../misc/test/undo.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var activity models.Activity
|
var activity models.Activity
|
||||||
json.Unmarshal(body, &activity)
|
json.Unmarshal(body, &activity)
|
||||||
@ -312,19 +312,19 @@ func mockActivity(req string) models.Activity {
|
|||||||
func mockActor(req string) models.Actor {
|
func mockActor(req string) models.Actor {
|
||||||
switch req {
|
switch req {
|
||||||
case "Person":
|
case "Person":
|
||||||
file, _ := os.Open("../misc/person.json")
|
file, _ := os.Open("../misc/test/person.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var actor models.Actor
|
var actor models.Actor
|
||||||
json.Unmarshal(body, &actor)
|
json.Unmarshal(body, &actor)
|
||||||
return actor
|
return actor
|
||||||
case "Service":
|
case "Service":
|
||||||
file, _ := os.Open("../misc/service.json")
|
file, _ := os.Open("../misc/test/service.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var actor models.Actor
|
var actor models.Actor
|
||||||
json.Unmarshal(body, &actor)
|
json.Unmarshal(body, &actor)
|
||||||
return actor
|
return actor
|
||||||
case "Application":
|
case "Application":
|
||||||
file, _ := os.Open("../misc/application.json")
|
file, _ := os.Open("../misc/test/application.json")
|
||||||
body, _ := ioutil.ReadAll(file)
|
body, _ := ioutil.ReadAll(file)
|
||||||
var actor models.Actor
|
var actor models.Actor
|
||||||
json.Unmarshal(body, &actor)
|
json.Unmarshal(body, &actor)
|
||||||
|
@ -123,7 +123,7 @@ func TestExportConfig(t *testing.T) {
|
|||||||
app.SetArgs([]string{"export"})
|
app.SetArgs([]string{"export"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
file, err := os.Open("../misc/blankConfig.json")
|
file, err := os.Open("../misc/test/blankConfig.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test resource fetch error.")
|
t.Fatalf("Test resource fetch error.")
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ func TestImportConfig(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ func TestImportConfig(t *testing.T) {
|
|||||||
app.SetArgs([]string{"export"})
|
app.SetArgs([]string{"export"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
file, err := os.Open("../misc/exampleConfig.json")
|
file, err := os.Open("../misc/test/exampleConfig.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test resource fetch error.")
|
t.Fatalf("Test resource fetch error.")
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ import (
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testConfigPath := "../misc/config.yml"
|
testConfigPath := "../misc/test/config.yml"
|
||||||
file, _ := os.Open(testConfigPath)
|
file, _ := os.Open(testConfigPath)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.ReadConfig(file)
|
viper.ReadConfig(file)
|
||||||
viper.Set("ACTOR_PEM", "../misc/testKey.pem")
|
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||||
viper.BindEnv("REDIS_URL")
|
viper.BindEnv("REDIS_URL")
|
||||||
|
|
||||||
globalConfig, err = models.NewRelayConfig()
|
globalConfig, err = models.NewRelayConfig()
|
||||||
|
@ -10,7 +10,7 @@ func TestListDomainSubscriber(t *testing.T) {
|
|||||||
relayState.RedisClient.FlushAll().Result()
|
relayState.RedisClient.FlushAll().Result()
|
||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ func TestListDomainLimited(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ func TestListDomainBlocked(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func TestUnsetDomainBlocked(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
app = domainCmdInit()
|
app = domainCmdInit()
|
||||||
@ -155,7 +155,7 @@ func TestUnsetDomainLimited(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
app = domainCmdInit()
|
app = domainCmdInit()
|
||||||
@ -180,7 +180,7 @@ func TestSetDomainInvalid(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ func TestUnfollowDomain(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
app = domainCmdInit()
|
app = domainCmdInit()
|
||||||
@ -227,7 +227,7 @@ func TestInvalidUnfollowDomain(t *testing.T) {
|
|||||||
|
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
relayState.Load()
|
relayState.Load()
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ func TestInvalidRejectFollow(t *testing.T) {
|
|||||||
func TestCreateUpdateActorActivity(t *testing.T) {
|
func TestCreateUpdateActorActivity(t *testing.T) {
|
||||||
app := configCmdInit()
|
app := configCmdInit()
|
||||||
|
|
||||||
app.SetArgs([]string{"import", "--json", "../misc/exampleConfig.json"})
|
app.SetArgs([]string{"import", "--json", "../misc/test/exampleConfig.json"})
|
||||||
app.Execute()
|
app.Execute()
|
||||||
|
|
||||||
app = followCmdInit()
|
app = followCmdInit()
|
||||||
|
@ -16,13 +16,13 @@ import (
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testConfigPath := "../misc/config.yml"
|
testConfigPath := "../misc/test/config.yml"
|
||||||
file, _ := os.Open(testConfigPath)
|
file, _ := os.Open(testConfigPath)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.ReadConfig(file)
|
viper.ReadConfig(file)
|
||||||
viper.Set("ACTOR_PEM", "../misc/testKey.pem")
|
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||||
viper.BindEnv("REDIS_URL")
|
viper.BindEnv("REDIS_URL")
|
||||||
|
|
||||||
globalConfig, err = models.NewRelayConfig()
|
globalConfig, err = models.NewRelayConfig()
|
||||||
|
@ -15,13 +15,13 @@ var ch chan bool
|
|||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testConfigPath := "../misc/config.yml"
|
testConfigPath := "../misc/test/config.yml"
|
||||||
file, _ := os.Open(testConfigPath)
|
file, _ := os.Open(testConfigPath)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.ReadConfig(file)
|
viper.ReadConfig(file)
|
||||||
viper.Set("ACTOR_PEM", "../misc/testKey.pem")
|
viper.Set("ACTOR_PEM", "../misc/test/testKey.pem")
|
||||||
viper.BindEnv("REDIS_URL")
|
viper.BindEnv("REDIS_URL")
|
||||||
|
|
||||||
globalConfig, err = NewRelayConfig()
|
globalConfig, err = NewRelayConfig()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user