summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-08-31 10:55:05 +0300
committerPaul Buetow <paul@buetow.org>2024-08-31 10:55:05 +0300
commitb923d7fc679901d9724cdd9ba4450e8eea448168 (patch)
tree7dbd228e24578a1b738b399932f823453236888a /internal/server
parent3f0dfd23836de58645a938ad3cb469777e8450e2 (diff)
refactored entry.Shared to be a map
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/repository/repository_test.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/internal/server/repository/repository_test.go b/internal/server/repository/repository_test.go
index b4eb0c2..72bc52d 100644
--- a/internal/server/repository/repository_test.go
+++ b/internal/server/repository/repository_test.go
@@ -251,12 +251,16 @@ func TestRepositoryMergeFromPartner(t *testing.T) {
}
// Validate the correct test setup
- if ent.Shared[1].Name != "LinkedIn" || ent.Shared[1].Is != false {
- t.Error("for the test expected LinkedIn not to be shared", ent.Shared[1])
+ if ent.IsShared("LinkedIn") {
+ t.Error("for the test expected LinkedIn not to be shared")
}
// Simulate that the entry was shared to LinkedIn social media!
- ent.Shared[1].Is = true
+ linkedIn, ok := ent.Shared["LinkedIn"]
+ if !ok {
+ t.Error("expected to have a LinkedIn shared entry")
+ }
+ linkedIn.Is = true
if err := repo1.Update(ent); err != nil {
t.Error(err)
}
@@ -304,10 +308,10 @@ func makeAnEntry() (types.Entry, error) {
entry := `
{
"Body": "Body text here",
- "Shared": [
- { "Name": "Mastodon", "Is": true },
- { "Name": "LinkedIn", "Is": false }
- ]
+ "Shared": {
+ "Mastodon": { "Is": true },
+ "LinkedIn": { "Is": false }
+ }
}
`
return types.NewEntry([]byte(entry))
@@ -317,11 +321,11 @@ func makeAnotherEntry() (types.Entry, error) {
entry := `
{
"Body": "Another text here",
- "Shared": [
- { "Name": "Mastodon", "Is": true },
- { "Name": "LinkedIn", "Is": true },
- { "Name": "foo.zone", "Is": false }
- ]
+ "Shared": {
+ "Mastodon": { "Is": true },
+ "LinkedIn": { "Is": true },
+ "foo.zone": { "Is": false }
+ }
}
`
return types.NewEntry([]byte(entry))