MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / EncodeTestVersion

Function EncodeTestVersion

db/utilities_hlv_testing.go:271–286  ·  view source on GitHub ↗

EncodeTestVersion converts a simplified string version of the form 1@abc to a hex-encoded version and base64 encoded source, like 169a05acd705ffc0@YWJj. Allows use of simplified versions in tests for readability, ease of use.

(versionString string)

Source from the content-addressed store, hash-verified

269// EncodeTestVersion converts a simplified string version of the form 1@abc to a hex-encoded version and base64 encoded
270// source, like 169a05acd705ffc0@YWJj. Allows use of simplified versions in tests for readability, ease of use.
271func EncodeTestVersion(versionString string) (encodedString string) {
272 timestampString, source, found := strings.Cut(versionString, "@")
273 if !found {
274 return versionString
275 }
276 if len(timestampString) > 0 && timestampString[0] == ' ' {
277 timestampString = timestampString[1:]
278 }
279 timestampUint, err := strconv.ParseUint(timestampString, 10, 64)
280 if err != nil {
281 return ""
282 }
283 hexTimestamp := strconv.FormatUint(timestampUint, 16)
284 base64Source := EncodeSource(source)
285 return hexTimestamp + "@" + base64Source
286}
287
288// GetHelperBody returns the body contents of a document written by HLVAgent.
289func (h *HLVAgent) GetHelperBody() string {

Callers 2

TestPutRevV4Function · 0.92
EncodeTestHistoryFunction · 0.85

Calls 1

EncodeSourceFunction · 0.85

Tested by 1

TestPutRevV4Function · 0.74