(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func 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 | |
| 119 | func TestCreate(t *testing.T) { |
| 120 | Convey("test create", t, func() { |
nothing calls this directly
no test coverage detected