Skip to content

Commit

Permalink
changes to remove repeated code, assuming from the rebase?
Browse files Browse the repository at this point in the history
  • Loading branch information
gregns1 committed Nov 7, 2023
1 parent 1ac3b1a commit a78fae7
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 63 deletions.
8 changes: 0 additions & 8 deletions db/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1969,14 +1969,6 @@ func (db *DatabaseCollectionWithUser) updateAndReturnDoc(ctx context.Context, do
// update the mutate in options based on the above logic
updatedSpec = doc.SyncData.HLV.computeMacroExpansions()

// update the HLV values
doc, err = db.updateHLV(doc, docUpdateEvent)
if err != nil {
return
}
// update the mutate in options based on the above logic
updatedSpec = doc.SyncData.HLV.computeMacroExpansions()

deleteDoc = currentRevFromHistory.Deleted

// Return the new raw document value for the bucket to store.
Expand Down
10 changes: 5 additions & 5 deletions rest/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@ func TestUpdateExistingAttachment(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const (
Expand Down Expand Up @@ -2326,7 +2326,7 @@ func TestPushUnknownAttachmentAsStub(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const doc1ID = "doc1"
Expand Down Expand Up @@ -2373,7 +2373,7 @@ func TestMinRevPosWorkToAvoidUnnecessaryProveAttachment(t *testing.T) {
},
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const docID = "doc"
Expand Down Expand Up @@ -2410,7 +2410,7 @@ func TestAttachmentWithErroneousRevPos(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

btc.Run(func(t *testing.T) {
Expand Down Expand Up @@ -2588,7 +2588,7 @@ func TestCBLRevposHandling(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const (
Expand Down
20 changes: 10 additions & 10 deletions rest/blip_api_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestBlipPushPullV2AttachmentV2Client(t *testing.T) {
opts.SupportedBLIPProtocols = []string{db.BlipCBMobileReplicationV2}
// given this test is for v2 protocol, skip version vector test
opts.SkipVersionVectorInitialization = true
btc := NewBlipTesterClientOptsWithRT(opts)
btc := NewBlipTesterClientOpts(opts)
defer btc.Close()
const docID = "doc1"

Expand Down Expand Up @@ -115,7 +115,7 @@ func TestBlipPushPullV2AttachmentV3Client(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()
const docID = "doc1"

Expand Down Expand Up @@ -170,7 +170,7 @@ func TestBlipProveAttachmentV2(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SupportedBLIPProtocols: []string{db.BlipCBMobileReplicationV2},
SkipVersionVectorInitialization: true,
})
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestBlipProveAttachmentV2Push(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SupportedBLIPProtocols: []string{db.BlipCBMobileReplicationV2},
SkipVersionVectorInitialization: true,
})
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestBlipPushPullNewAttachmentCommonAncestor(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const docID = "doc1"
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestBlipPushPullNewAttachmentNoCommonAncestor(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()

const docID = "doc1"
Expand Down Expand Up @@ -510,7 +510,7 @@ func TestBlipAttachNameChange(t *testing.T) {
GuestEnabled: true,
}

client1 := NewBlipTesterClientOptsWithRT(nil)
client1 := NewBlipTesterClientOpts(nil)
defer client1.Close()
base.SetUpTestLogging(t, base.LevelInfo, base.KeySync, base.KeySyncMsg, base.KeyWebSocket, base.KeyWebSocketFrame, base.KeyHTTP, base.KeyCRUD)

Expand Down Expand Up @@ -552,7 +552,7 @@ func TestBlipLegacyAttachNameChange(t *testing.T) {
rtConfig := &RestTesterConfig{
GuestEnabled: true,
}
client1 := NewBlipTesterClientOptsWithRT(nil)
client1 := NewBlipTesterClientOpts(nil)
defer client1.Close()
base.SetUpTestLogging(t, base.LevelInfo, base.KeySync, base.KeySyncMsg, base.KeyWebSocket, base.KeyWebSocketFrame, base.KeyHTTP, base.KeyCRUD)

Expand Down Expand Up @@ -604,7 +604,7 @@ func TestBlipLegacyAttachDocUpdate(t *testing.T) {
GuestEnabled: true,
}

client1 := NewBlipTesterClientOptsWithRT(nil)
client1 := NewBlipTesterClientOpts(nil)
defer client1.Close()
base.SetUpTestLogging(t, base.LevelInfo, base.KeySync, base.KeySyncMsg, base.KeyWebSocket, base.KeyWebSocketFrame, base.KeyHTTP, base.KeyCRUD)

Expand Down Expand Up @@ -677,7 +677,7 @@ func TestAttachmentComputeStat(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()
const docID = "doc1"

Expand Down
12 changes: 6 additions & 6 deletions rest/blip_api_collections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestBlipGetCollections(t *testing.T) {

const defaultScopeAndCollection = "_default._default"
rtConfig := &RestTesterConfig{GuestEnabled: true}
btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SkipCollectionsInitialization: true,
NumCollectionsRequired: 1,
})
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestBlipReplicationNoDefaultCollection(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SkipVersionVectorInitialization: true, // no need for version vector test here
})
defer btc.Close()
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestBlipGetCollectionsAndSetCheckpoint(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SkipVersionVectorInitialization: true, // no need for version vector test here
})
defer btc.Close()
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestCollectionsReplication(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()
const docID = "doc1"

Expand All @@ -262,7 +262,7 @@ func TestBlipReplicationMultipleCollections(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{NumCollectionsRequired: 2})
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{NumCollectionsRequired: 2})
defer btc.Close()

btc.Run(func(t *testing.T) {
Expand Down Expand Up @@ -299,7 +299,7 @@ func TestBlipReplicationMultipleCollectionsMismatchedDocSizes(t *testing.T) {
GuestEnabled: true,
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{NumCollectionsRequired: 2})
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{NumCollectionsRequired: 2})
defer btc.Close()

btc.Run(func(t *testing.T) {
Expand Down
23 changes: 11 additions & 12 deletions rest/blip_api_crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ func TestBlipPullRevMessageHistory(t *testing.T) {
GuestEnabled: true,
}

client := NewBlipTesterClientOptsWithRT(nil)
client := NewBlipTesterClientOpts(nil)
defer client.Close()
client.ClientDeltas = true
const docID = "doc1"
Expand Down Expand Up @@ -1873,7 +1873,7 @@ func TestActiveOnlyContinuous(t *testing.T) {

rtConfig := &RestTesterConfig{GuestEnabled: true}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()
const docID = "doc1"

Expand Down Expand Up @@ -1902,7 +1902,7 @@ func TestBlipNorev(t *testing.T) {

rtConfig := &RestTesterConfig{GuestEnabled: true}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SkipVersionVectorInitialization: true, // no rev has different handling for VV
})
defer btc.Close()
Expand Down Expand Up @@ -1952,7 +1952,7 @@ func TestRemovedMessageWithAlternateAccess(t *testing.T) {

rtConfig := &RestTesterConfig{SyncFn: channels.DocChannelsSyncFunction}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
Username: "user",
Channels: []string{"*"},
ClientDeltas: false,
Expand Down Expand Up @@ -2060,7 +2060,7 @@ func TestRemovedMessageWithAlternateAccessAndChannelFilteredReplication(t *testi

rtConfig := &RestTesterConfig{SyncFn: channels.DocChannelsSyncFunction}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
Username: "user",
Channels: []string{"*"},
ClientDeltas: false,
Expand All @@ -2073,7 +2073,6 @@ func TestRemovedMessageWithAlternateAccessAndChannelFilteredReplication(t *testi
)

btc.Run(func(t *testing.T) {
// can we remove?
collection := btc.rt.GetSingleTestDatabaseCollection()
resp := btc.rt.SendAdminRequest("PUT", "/db/_user/user", GetUserPayload(t, "user", "test", "", collection, []string{"A", "B"}, nil))
RequireStatus(t, resp, http.StatusOK)
Expand Down Expand Up @@ -2369,7 +2368,7 @@ func TestBlipInternalPropertiesHandling(t *testing.T) {
GuestEnabled: true,
}

client := NewBlipTesterClientOptsWithRT(nil)
client := NewBlipTesterClientOpts(nil)
defer client.Close()

client.Run(func(t *testing.T) {
Expand Down Expand Up @@ -2536,7 +2535,7 @@ func TestSendRevisionNoRevHandling(t *testing.T) {
CustomTestBucket: base.GetTestBucket(t).LeakyBucketClone(base.LeakyBucketConfig{}),
}

btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{
SkipVersionVectorInitialization: true, // no rev has different handling for VV
})
defer btc.Close()
Expand Down Expand Up @@ -2611,7 +2610,7 @@ func TestUnsubChanges(t *testing.T) {
base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll)
rtConfig := &RestTesterConfig{GuestEnabled: true}

btc := NewBlipTesterClientOptsWithRT(nil)
btc := NewBlipTesterClientOpts(nil)
defer btc.Close()
const (
doc1ID = "doc1ID"
Expand Down Expand Up @@ -2678,7 +2677,7 @@ func TestRequestPlusPull(t *testing.T) {
}

// Initialize blip tester client (will create user)
client := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
client := NewBlipTesterClientOpts(&BlipTesterClientOpts{
Username: "bernard",
})
defer client.Close()
Expand Down Expand Up @@ -2738,7 +2737,7 @@ func TestRequestPlusPullDbConfig(t *testing.T) {
}

// Initialize blip tester client (will create user)
client := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{
client := NewBlipTesterClientOpts(&BlipTesterClientOpts{
Username: "bernard",
})
defer client.Close()
Expand Down Expand Up @@ -2800,7 +2799,7 @@ func TestBlipRefreshUser(t *testing.T) {

const username = "bernard"
// Initialize blip tester client (will create user)
btc := NewBlipTesterClientOptsWithRT(&BlipTesterClientOpts{ // This test will need refactoring when its getting fixed in CBG-3512
btc := NewBlipTesterClientOpts(&BlipTesterClientOpts{ // This test will need refactoring when its getting fixed in CBG-3512
Username: "bernard",
Channels: []string{"chan1"},
})
Expand Down
Loading

0 comments on commit a78fae7

Please sign in to comment.