Skip to content

Commit

Permalink
plugin: add tests to test the plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Jul 26, 2022
1 parent 3b33db3 commit 0022e0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugin/example/simple_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (instance *OnRPCCommand[T]) Call(plugin *plugin.Plugin[T], request map[stri
type Hello[T PluginState] struct{}

func (instance *Hello[T]) Call(plugin *plugin.Plugin[T], request map[string]any) (map[string]any, error) {
return map[string]any{"hello": "hello from go 1.18"}, nil
return map[string]any{"message": "hello from go 1.18"}, nil
}

func main() {
Expand Down
25 changes: 25 additions & 0 deletions plugin/plugin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package plugin

import (
"os"
"testing"

"github.com/vincenzopalazzo/cln4go/client"
)

func TestCallFistMethod(t *testing.T) {
path := os.Getenv("CLN_UNIX_SOCKET")
client, err := client.NewUnix(path)
if err != nil {
panic(err)
}
response, err := client.Call("hello", make(map[string]interface{}))
message, found := response["message"]
if !found {
t.Error("The message is not found")
}

if message != "hello from go 1.18" {
t.Error("message received %s different from expected %s", message, "hello from go 1.18")
}
}

0 comments on commit 0022e0e

Please sign in to comment.