diff options
Diffstat (limited to 'api/payload_test.go')
-rw-r--r-- | api/payload_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/api/payload_test.go b/api/payload_test.go index f890fe6..fe52ed1 100644 --- a/api/payload_test.go +++ b/api/payload_test.go @@ -138,6 +138,33 @@ func TestUpdateFeedUsernameWhenNotSet(t *testing.T) { } } +func TestUpdateFeedDisabled(t *testing.T) { + valueTrue := true + valueFalse := false + scenarios := []struct { + changes *feedModification + feed *model.Feed + expected bool + }{ + {&feedModification{}, &model.Feed{Disabled: true}, true}, + {&feedModification{Disabled: &valueTrue}, &model.Feed{Disabled: true}, true}, + {&feedModification{Disabled: &valueFalse}, &model.Feed{Disabled: true}, false}, + {&feedModification{}, &model.Feed{Disabled: false}, false}, + {&feedModification{Disabled: &valueTrue}, &model.Feed{Disabled: false}, true}, + {&feedModification{Disabled: &valueFalse}, &model.Feed{Disabled: false}, false}, + } + + for _, scenario := range scenarios { + scenario.changes.Update(scenario.feed) + if scenario.feed.Disabled != scenario.expected { + t.Errorf(`Unexpected result, got %v, want: %v`, + scenario.feed.Disabled, + scenario.expected, + ) + } + } +} + func TestUpdateFeedCategory(t *testing.T) { categoryID := int64(1) changes := &feedModification{CategoryID: &categoryID} |