Skip to content

Commit

Permalink
add test validations
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Mar 7, 2023
1 parent 6745f1d commit 2b0e7f1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/sync/file/filepath_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,19 @@ func TestSimpleSync(t *testing.T) {

dataSyncChan := make(chan sync.DataSync, len(tt.expectedDataSync))

syncHandler := Sync{
URI: fmt.Sprintf("%s/%s", fetchDirName, fetchFileName),
Logger: logger.NewLogger(nil, false),
Mux: &msync.RWMutex{},
}

go func() {
handler := Sync{
URI: fmt.Sprintf("%s/%s", fetchDirName, fetchFileName),
Logger: logger.NewLogger(nil, false),
Mux: &msync.RWMutex{},
}
err := handler.Init(ctx)
err := syncHandler.Init(ctx)
if err != nil {
log.Fatalf("Error init sync: %s", err.Error())
return
}
err = handler.Sync(ctx, dataSyncChan)
err = syncHandler.Sync(ctx, dataSyncChan)
if err != nil {
log.Fatalf("Error start sync: %s", err.Error())
return
Expand Down Expand Up @@ -187,6 +188,11 @@ func TestSimpleSync(t *testing.T) {
case <-time.After(10 * time.Second):
t.Errorf("event not found, timeout out after 10 seconds")
}

// validate readiness - readiness must not change
if syncHandler.ready != true {
t.Errorf("readiness must be set to true, but found: %t", syncHandler.ready)
}
}
})
}
Expand Down

0 comments on commit 2b0e7f1

Please sign in to comment.