Skip to content

Commit

Permalink
test: port rcmgr sharness tests to Go
Browse files Browse the repository at this point in the history
  • Loading branch information
guseggert authored and lidel committed Feb 28, 2023
1 parent cf9276d commit 145795b
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 284 deletions.
13 changes: 13 additions & 0 deletions test/cli/harness/node.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package harness

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -62,6 +63,18 @@ func BuildNode(ipfsBin, baseDir string, id int) *Node {
}
}

func (n *Node) WriteBytes(filename string, b []byte) {
f, err := os.Create(filepath.Join(n.Dir, filename))
if err != nil {
panic(err)
}
defer f.Close()
_, err = io.Copy(f, bytes.NewReader(b))
if err != nil {
panic(err)
}
}

func (n *Node) ReadConfig() *config.Config {
cfg, err := serial.Load(filepath.Join(n.Dir, "config"))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions test/cli/harness/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type RunResult struct {
Cmd *exec.Cmd
}

func (r *RunResult) ExitCode() int {
return r.Cmd.ProcessState.ExitCode()
}

func environToMap(environ []string) map[string]string {
m := map[string]string{}
for _, e := range environ {
Expand Down
Loading

0 comments on commit 145795b

Please sign in to comment.