Skip to content

Commit

Permalink
added default config file
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Feb 11, 2021
1 parent f65602e commit d22467d
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions clab/config_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
package clab

import (
"io/ioutil"
"log"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
)

func init() {

// create default config file for srl to let parse topology func to pass
if _, err := os.Stat(defaultConfigTemplates["srl"]); err != nil {
ferr := ioutil.WriteFile(defaultConfigTemplates["srl"], []byte("testing file"), 0600)
if ferr != nil {
log.Fatal(err)
}
}
}

func TestLicenseInit(t *testing.T) {
tests := map[string]struct {
got string
Expand Down Expand Up @@ -40,16 +54,8 @@ func TestLicenseInit(t *testing.T) {
t.Fatal(err)
}

nodeCfg := c.Config.Topology.Nodes["node1"]
node := Node{}
node.Kind = strings.ToLower(c.kindInitialization(&nodeCfg))

lic, err := c.licenseInit(&nodeCfg, &node)
if err != nil {
t.Fatal(err)
}
if filepath.Base(lic) != tc.want {
t.Fatalf("wanted '%s' got '%s'", tc.want, lic)
if filepath.Base(c.Nodes["node1"].License) != tc.want {
t.Fatalf("wanted '%s' got '%s'", tc.want, c.Nodes["node1"].License)
}
})
}
Expand Down Expand Up @@ -147,13 +153,13 @@ func TestTypeInit(t *testing.T) {
t.Fatal(err)
}

nodeCfg := c.Config.Topology.Nodes[tc.node]
node := Node{}
node.Kind = strings.ToLower(c.kindInitialization(&nodeCfg))
// nodeCfg := c.Config.Topology.Nodes[tc.node]
// node := Node{}
// node.Kind = strings.ToLower(c.kindInitialization(&nodeCfg))

ntype := c.typeInit(&nodeCfg, node.Kind)
if !reflect.DeepEqual(ntype, tc.want) {
t.Fatalf("wanted %q got %q", tc.want, ntype)
// ntype := c.typeInit(&nodeCfg, node.Kind)
if !reflect.DeepEqual(c.Nodes[tc.node].NodeType, tc.want) {
t.Fatalf("wanted %q got %q", tc.want, c.Nodes[tc.node].NodeType)
}
})
}
Expand Down

0 comments on commit d22467d

Please sign in to comment.