Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Sep 20, 2024
1 parent 231af33 commit 7fc4782
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
3 changes: 3 additions & 0 deletions services/datamanager/builtin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (c *Config) Validate(path string) ([]string, error) {
if c.SyncIntervalMins < 0 {
return nil, errors.New("sync_interval_mins can't be negative")
}
if c.MaximumNumSyncThreads < 0 {
return nil, errors.New("maximum_num_sync_threads can't be negative")
}
if c.FileLastModifiedMillis < 0 {
return nil, errors.New("file_last_modified_millis can't be negative")
}
Expand Down
60 changes: 55 additions & 5 deletions services/datamanager/builtin/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package builtin

import (
"errors"
"runtime"
"testing"

Expand All @@ -27,11 +28,60 @@ var fullConfig = &Config{
}

func TestConfig(t *testing.T) {
t.Run("Validate returns the internal cloud service name", func(t *testing.T) {
c := &Config{}
deps, err := c.Validate("")
test.That(t, err, test.ShouldBeNil)
test.That(t, deps, test.ShouldResemble, []string{cloud.InternalServiceName.String()})
t.Run("Validate ", func(t *testing.T) {
type testCase struct {
name string
config Config
deps []string
err error
}

tcs := []testCase{
{
name: "returns the internal cloud service name when valid",
config: Config{},
deps: []string{cloud.InternalServiceName.String()},
},
{
name: "returns an error if SyncIntervalMins is negative",
config: Config{SyncIntervalMins: -1},
err: errors.New("sync_interval_mins can't be negative"),
},
{
name: "returns an error if MaximumNumSyncThreads is negative",
config: Config{MaximumNumSyncThreads: -1},
err: errors.New("maximum_num_sync_threads can't be negative"),
},
{
name: "returns an error if FileLastModifiedMillis is negative",
config: Config{FileLastModifiedMillis: -1},
err: errors.New("file_last_modified_millis can't be negative"),
},
{
name: "returns an error if MaximumCaptureFileSizeBytes is negative",
config: Config{MaximumCaptureFileSizeBytes: -1},
err: errors.New("maximum_capture_file_size_bytes can't be negative"),
},
{
name: "returns an error if DeleteEveryNthWhenDiskFull is negative",
config: Config{DeleteEveryNthWhenDiskFull: -1},
err: errors.New("delete_every_nth_when_disk_full can't be negative"),
},
}

for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
deps, err := tc.config.Validate("")
if tc.err == nil {
test.That(t, err, test.ShouldBeNil)

} else {
test.That(t, err, test.ShouldBeError, tc.err)
}
test.That(t, deps, test.ShouldResemble, tc.deps)

})
}
})

t.Run("getCaptureDir", func(t *testing.T) {
Expand Down

0 comments on commit 7fc4782

Please sign in to comment.