MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestDefaultInit

Function TestDefaultInit

client/driver_test.go:70–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestDefaultInit(t *testing.T) {
71 log.SetLevel(log.DebugLevel)
72 // test defaultInit
73 Convey("test defaultInit", t, func() {
74 var stopTestService func()
75 var confDir string
76 var err error
77
78 // check and prepare ~/.cql
79 homePath := utils.HomeDirExpand("~/.cql")
80 if utils.Exist(homePath) {
81 return
82 }
83
84 // no config err
85 err = defaultInit()
86 So(err, ShouldNotBeNil)
87
88 err = os.Mkdir(homePath, 0755)
89 So(err, ShouldBeNil)
90 defer os.RemoveAll(homePath)
91
92 stopTestService, confDir, err = startTestService()
93 So(err, ShouldBeNil)
94 defer stopTestService()
95
96 // copy standalone conf
97 confFile := filepath.Join(confDir, "config.yaml")
98 privateKeyFile := filepath.Join(confDir, "private.key")
99 homeConfig := filepath.Join(homePath, "config.yaml")
100 homeKey := filepath.Join(homePath, "private.key")
101 _, err = utils.CopyFile(confFile, homeConfig)
102 So(err, ShouldBeNil)
103 _, err = utils.CopyFile(privateKeyFile, homeKey)
104 So(err, ShouldBeNil)
105
106 // fake driver not initialized
107 atomic.StoreUint32(&driverInitialized, 0)
108
109 // no err
110 err = defaultInit()
111 So(err, ShouldBeNil)
112
113 // clean
114 stopPeersUpdater()
115 atomic.StoreUint32(&driverInitialized, 0)
116 })
117}
118
119func TestCreate(t *testing.T) {
120 Convey("test create", t, func() {

Callers

nothing calls this directly

Calls 8

SetLevelFunction · 0.92
HomeDirExpandFunction · 0.92
ExistFunction · 0.92
CopyFileFunction · 0.92
defaultInitFunction · 0.85
startTestServiceFunction · 0.85
stopPeersUpdaterFunction · 0.85
MkdirMethod · 0.80

Tested by

no test coverage detected