1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

moved errorLog test to request testing

This commit is contained in:
postmannen 2022-05-23 15:11:58 +02:00
parent e6006b44d3
commit f983148d46
2 changed files with 18 additions and 22 deletions

View file

@ -108,7 +108,8 @@ func TestRequest(t *testing.T) {
} }
defer ns.Shutdown() defer ns.Shutdown()
tempdir := t.TempDir() // tempdir := t.TempDir()
tempdir := "tmp"
srv, conf := newServerForTesting(t, "127.0.0.1:42222", tempdir) srv, conf := newServerForTesting(t, "127.0.0.1:42222", tempdir)
srv.Start() srv.Start()
defer srv.Stop() defer srv.Stop()
@ -126,6 +127,22 @@ func TestRequest(t *testing.T) {
} }
tests := []test{ tests := []test{
{
info: "REQHello test",
message: Message{
ToNode: "errorCentral",
FromNode: "errorCentral",
Method: REQErrorLog,
MethodArgs: []string{},
MethodTimeout: 5,
Data: []byte("error data"),
// ReplyMethod: REQTest,
Directory: "error_log",
FileName: "error.results",
}, want: []byte("error data"),
containsOrEquals: fileContains,
viaSocketOrCh: viaCh,
},
{ {
info: "REQHello test", info: "REQHello test",
message: Message{ message: Message{

View file

@ -58,7 +58,6 @@ func TestStewardServer(t *testing.T) {
// Specify all the test funcs to run in the slice. // Specify all the test funcs to run in the slice.
funcs := []testFunc{ funcs := []testFunc{
checkREQErrorLogTest,
checkREQTailFileTest, checkREQTailFileTest,
checkErrorKernelMalformedJSONtest, checkErrorKernelMalformedJSONtest,
checkMetricValuesTest, checkMetricValuesTest,
@ -77,26 +76,6 @@ func TestStewardServer(t *testing.T) {
// Check REQ types // Check REQ types
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Check the error logger type.
func checkREQErrorLogTest(stewardServer *server, conf *Configuration, t *testing.T, tempDir string) error {
m := Message{
ToNode: "somenode",
}
p := newProcess(stewardServer.ctx, stewardServer, Subject{}, processKindSubscriber, nil)
stewardServer.errorKernel.errSend(p, m, fmt.Errorf("some error"))
resultFile := filepath.Join(conf.SubscribersDataFolder, "errorLog", "errorCentral", "error.log")
_, err := findStringInFileTest("some error", resultFile, conf, t)
if err != nil {
return fmt.Errorf(" \U0001F631 [FAILED] : checkREQErrorLogTest: %v", err)
}
t.Logf(" \U0001f600 [SUCCESS] : checkREQErrorLogTest\n")
return nil
}
// Check the tailing of files type. // Check the tailing of files type.
func checkREQTailFileTest(stewardServer *server, conf *Configuration, t *testing.T, tmpDir string) error { func checkREQTailFileTest(stewardServer *server, conf *Configuration, t *testing.T, tmpDir string) error {
// Create a file with some content. // Create a file with some content.