Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 44f0c42

Browse files
authoredMay 16, 2023
RSDK-2961 Default use_live_data to true (#193)
1 parent 17a343e commit 44f0c42

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
 

‎config/config.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ func DetermineDeleteProcessedData(logger golog.Logger, deleteData *bool, useLive
3232
// DetermineUseLiveData will determine the value of the useLiveData attribute
3333
// based on the liveData input parameter and sensor list.
3434
func DetermineUseLiveData(logger golog.Logger, liveData *bool, sensors []string) (bool, error) {
35+
// If liveData is not set, default it to true and require a sensor to have been provided.
3536
if liveData == nil {
36-
return false, newError("use_live_data is a required input parameter")
37+
if len(sensors) == 0 {
38+
return false, newError("sensors field cannot be empty")
39+
}
40+
return true, nil
3741
}
42+
3843
useLiveData := *liveData
3944
if useLiveData && len(sensors) == 0 {
4045
return false, newError("sensors field cannot be empty when use_live_data is set to true")
@@ -64,10 +69,6 @@ func (config *Config) Validate(path string) ([]string, error) {
6469
return nil, utils.NewConfigValidationFieldRequiredError(path, "data_dir")
6570
}
6671

67-
if config.UseLiveData == nil {
68-
return nil, utils.NewConfigValidationFieldRequiredError(path, "use_live_data")
69-
}
70-
7172
if config.DataRateMsec < 0 {
7273
return nil, errors.New("cannot specify data_rate_msec less than zero")
7374
}

‎config/config_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestValidate(t *testing.T) {
3434

3535
t.Run("Config without required fields", func(t *testing.T) {
3636
// Test for missing main attribute fields
37-
requiredFields := []string{"data_dir", "use_live_data"}
37+
requiredFields := []string{"data_dir"}
3838
for _, requiredField := range requiredFields {
3939
logger.Debugf("Testing SLAM config without %s\n", requiredField)
4040
cfgService := makeCfgService()
@@ -131,12 +131,12 @@ func TestDetermineUseLiveData(t *testing.T) {
131131
logger := golog.NewTestLogger(t)
132132
t.Run("No use_live_data specified", func(t *testing.T) {
133133
useLiveData, err := DetermineUseLiveData(logger, nil, []string{})
134-
test.That(t, err, test.ShouldBeError, newError("use_live_data is a required input parameter"))
134+
test.That(t, err, test.ShouldBeError, newError("sensors field cannot be empty"))
135135
test.That(t, useLiveData, test.ShouldBeFalse)
136136

137137
useLiveData, err = DetermineUseLiveData(logger, nil, []string{"camera"})
138-
test.That(t, err, test.ShouldBeError, newError("use_live_data is a required input parameter"))
139-
test.That(t, useLiveData, test.ShouldBeFalse)
138+
test.That(t, err, test.ShouldBeNil)
139+
test.That(t, useLiveData, test.ShouldBeTrue)
140140
})
141141
t.Run("False use_live_data", func(t *testing.T) {
142142
useLiveData, err := DetermineUseLiveData(logger, &_false, []string{})

0 commit comments

Comments
 (0)
This repository has been archived.