Example #1
0
/**
 * TestToString
 */
func TestToString() {
	Couch = couch.New(nil, false)
	Client = couch.NewClient(Couch)
	Client.DoRequest("HEAD /", nil, "", nil)
	util.Dumpf("Request\n>>\n%s", Client.GetRequest().ToString())
	util.Dumpf("Response\n>>\n%s", Client.GetResponse().ToString())
}
Example #2
0
/**
 * TestClientResponseHeaders.
 */
func TestClientResponseHeaders(key string) {
	var response = _doRequest("GET /")
	if key == "" {
		util.Dumpf("Response Headers >> %+v", response.GetHeaderAll())
	} else {
		util.Dumpf("Response Headers >> %s: %+v", key, response.GetHeader(key))
	}
}
Example #3
0
/**
 * TestEnsureFullCommit
 */
func TestEnsureFullCommit() {
	ok, time, err := Database.EnsureFullCommit()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Ensure Full Commit >> ok: %v", ok)
	util.Dumpf("Database Ensure Full Commit >> instance_start_time: %d", time)
}
Example #4
0
/**
 * TestGetAllDatabases
 */
func TestGetAllDatabases() {
	data, err := Server.GetAllDatabases()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Server Databases >> %+v", data)
	util.Dumpf("Server Databases >> first: %s", data[0])
}
/**
 * TestFind
 */
func TestFind() {
	var docAttc = _documentAttachment("./attc.txt", "").Find()
	util.Dumpf("Document Attachment Find >> %v", docAttc)
	util.Dumpf("Document Attachment Find >> content: %s", docAttc["content"])
	util.Dumpf("Document Attachment Find >> content_type: %s", docAttc["content_type"])
	util.Dumpf("Document Attachment Find >> content_length: %d", docAttc["content_length"])
	util.Dumpf("Document Attachment Find >> digest: %s", docAttc["digest"])
}
Example #6
0
/**
 * TestFindAttachments
 */
func TestFindAttachments() {
	data, err := _document("_id", "attc_test").FindAttachments(false, nil)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Find Attachments >> %v", data)
	util.Dumpf("Document Find Attachments >> 0: %v", data[0])
	util.Dumpf("Document Find Attachments >> 0.content_type: %v", data[0]["content_type"])
}
Example #7
0
/**
 * TestReplicate
 */
func TestReplicate() {
	data, err := Database.Replicate("foo_replicate", true)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Replicate >> %+v", data)
	util.Dumpf("Database Replicate >> ok: %v", data["ok"])
	util.Dumpf("Database Replicate >> history.0: %v", util.Dig("0", data["history"]))
	util.Dumpf("Database Replicate >> history.0.start_time: %s", util.Dig("0.start_time", data["history"]))
}
Example #8
0
/**
 * TestGetSecurity
 */
func TestGetSecurity() {
	data, err := Database.GetSecurity()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Get Security >> %+v", data)
	util.Dumpf("Database Get Security >> admins %+v", data["admins"])
	util.Dumpf("Database Get Security >> admins.names.0 %s", util.Dig("admins.names.0", data))
	util.Dumpf("Database Get Security >> admins.roles.0 %s", util.Dig("admins.roles.0", data))
}
Example #9
0
/**
 * TestGetDatabaseUpdates
 */
func TestGetDatabaseUpdates() {
	data, err := Server.GetDatabaseUpdates(nil)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Server Updates >> %+v", data)
	util.Dumpf("Server Updates >> db_name: %s", data["db_name"])
	util.Dumpf("Server Updates >> type: %s", data["type"])
	util.Dumpf("Server Updates >> ok: %v", data["ok"])
}
Example #10
0
/**
 * TestGetUuids
 */
func TestGetUuids() {
	data, err := Server.GetUuids(3)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Server Uuids >> %+v", data)
	for i, _ := range data {
		util.Dumpf("Server Uuids >> %d: %s", i, data[i])
	}
}
Example #11
0
/**
 * TestGetActiveTasks
 */
func TestGetActiveTasks() {
	data, err := Server.GetActiveTasks()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Server Active Tasks >> %+v", data)
	for _, task := range data {
		util.Dumpf("Server Active Tasks >> 0.pid: %s", task["pid"])
		util.Dumpf("Server Active Tasks >> 0.database: %s", task["database"])
	}
}
Example #12
0
/**
 * TestInfo
 */
func TestInfo() {
	data, err := Database.Info()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Info >> %+v", data)
	util.Dumpf("Database Info >> db_name: %s", data["db_name"])
	for key, value := range data {
		util.Dumpf("Database Info >> %s: %v", key, value)
	}
}
Example #13
0
/**
 * TestFind
 */
func TestFind() {
	var doc = _document(
		"_id", "25ae622daf825dd1f2ec138b68007a10",
	)
	data, err := doc.Find(nil)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Find >> %v", data)
	util.Dumpf("Document Find >> _id: %s", data["_id"])
}
Example #14
0
/**
 * TestPurge
 */
func TestPurge() {
	data, err := Database.Purge(map[string]interface{}{
		"667b0208441066a0954717b50c0008a9": []string{
			"5-dd1a3738fcbd759ed744f7971fe94332",
		},
	})
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Purge >> %v", data)
	util.Dumpf("Database Purge >> purge_seq: %d", data["purge_seq"])
}
Example #15
0
/**
 * TestPing
 */
func TestPing() {
	var doc1 = _document(
		"_id", "25ae622daf825dd1f2ec138b68007a10",
	)
	var doc2 = _document(
		"_id", "25ae622daf825dd1f2ec138b68007a10",
		"_rev", "1-3c92d3e67136c8b206d90ea37a3ee76d",
	)
	util.Dumpf("Document Ping >> %v", doc1.Ping(200))
	util.Dumps("\n---\n")
	util.Dumpf("Document Ping >> %v", doc2.Ping(304))
}
Example #16
0
/**
 * TestFindRevisions
 */
func TestFindRevisions() {
	var doc = _document(
		"_id", "83b5e0a0b3bd41d9a21cee7ae8000615",
	)
	data, err := doc.FindRevisions()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Find Revisions >> %v", data)
	util.Dumpf("Document Find Revisions >> start: %d", data["start"])
	util.Dumpf("Document Find Revisions >> ids: %v", data["ids"])
	util.Dumpf("Document Find Revisions >> ids.0: %v", util.Dig("ids.0", data))
}
Example #17
0
/**
 * TestFindRevisionsExtended
 */
func TestFindRevisionsExtended() {
	var doc = _document(
		"_id", "83b5e0a0b3bd41d9a21cee7ae8000615",
	)
	data, err := doc.FindRevisionsExtended()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Find Revisions Extended >> %v", data)
	util.Dumpf("Document Find Revisions Extended >> 0: %v", data[0])
	util.Dumpf("Document Find Revisions Extended >> 0.rev: %s", data[0]["rev"])
	util.Dumpf("Document Find Revisions Extended >> 0.status: %s", data[0]["status"])
}
Example #18
0
/**
 * TestCopyTo
 */
func TestCopyTo() {
	var doc = _document(
		"_id", "go_test_attc_copy",
		"_rev", "1-52f1aa9c34a350b0867ea9e086132647",
	)
	data, err := doc.CopyTo("go_test_attc_copy_copy", "1-52f1aa9c34a350b0867ea9e086132647")
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Copy To >> %v", data)
	util.Dumpf("Document Copy To >> ok: %v", data["ok"])
	util.Dumpf("Document Copy To >> id: %v", data["id"])
	util.Dumpf("Document Copy To >> rev: %v", data["rev"])
}
Example #19
0
/**
 * TestRemove
 */
func TestRemove() {
	var doc = _document(
		"_id", "e90636c398458a9d5969d2e71b04bc2a",
		"_rev", "1-5637fdf6ae62130da1dda54be05d7da7",
	)
	data, err := doc.Remove()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Remove >> %v", data)
	util.Dumpf("Document Remove >> ok: %v", data["ok"])
	util.Dumpf("Document Remove >> id: %v", data["id"])
	util.Dumpf("Document Remove >> rev: %v", data["rev"])
}
Example #20
0
/**
 * TestReplicate
 */
func TestReplicate() {
	data, err := Server.Replicate(map[string]interface{}{
		"source":        "foo",
		"target":        "foo_replicate",
		"create_target": true,
	})
	if err != nil {
		panic(err)
	}
	util.Dumpf("Server Database Replicate >> %+v", data)
	util.Dumpf("Server Database Replicate >> ok: %v", data["ok"])
	util.Dumpf("Server Database Replicate >> history.0: %v", util.Dig("0", data["history"]))
	util.Dumpf("Server Database Replicate >> history.0.start_time: %s", util.Dig("0.start_time", data["history"]))
}
Example #21
0
/**
 * TestCopy
 */
func TestCopy() {
	var doc = _document(
		"_id", "go_test_attc",
		"_rev", "1-ffc2712342beba4770b9bbdb72d6eded",
	)
	data, err := doc.Copy("go_test_attc_copy")
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Copy >> %v", data)
	util.Dumpf("Document Copy >> ok: %v", data["ok"])
	util.Dumpf("Document Copy >> id: %v", data["id"])
	util.Dumpf("Document Copy >> rev: %v", data["rev"])
}
Example #22
0
/**
 * TestRemove
 */
func TestRemove() {
	var doc = couch.NewDocument(Database,
		"_id", "attc_test",
		"_rev", "16-744735fac2c0bc49ff17f6a8fb8145bf",
	)
	var docAttc = couch.NewDocumentAttachment(doc, "./attc.txt", "attc2.txt")
	data, err := docAttc.Remove(false, false)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Attachment Remove >> %v", data)
	util.Dumpf("Document Attachment Remove >> ok: %v", data["ok"])
	util.Dumpf("Document Attachment Remove >> id: %s", data["id"])
	util.Dumpf("Document Attachment Remove >> rev: %s", data["rev"])
}
Example #23
0
/**
 * TestSave
 */
func TestSave() {
	var doc = couch.NewDocument(Database,
		"_id", "attc_test",
		"_rev", "15-521ec44a6b39f3c5b40b20f94408dd57",
	)
	var docAttc = couch.NewDocumentAttachment(doc, "./attc.txt", "attc2.txt")
	data, err := docAttc.Save()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Document Attachment Save >> %v", data)
	util.Dumpf("Document Attachment Save >> ok: %v", data["ok"])
	util.Dumpf("Document Attachment Save >> id: %s", data["id"])
	util.Dumpf("Document Attachment Save >> rev: %s", data["rev"])
}
Example #24
0
/**
 * TestCompact
 */
func TestCompact() {
	ok, err := Database.Compact("")
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Compact >> ok: %v", ok)
}
Example #25
0
/**
 * TestIsNotModified
 */
func TestIsNotModified() {
	var doc = _document(
		"_id", "25ae622daf825dd1f2ec138b68007a10",
		"_rev", "1-3c92d3e67136c8b206d90ea37a3ee76d",
	)
	util.Dumpf("Document Is Not Modified >> %v", doc.IsNotModified())
}
Example #26
0
/**
 * TestCreateDocument
 */
func TestCreateDocument() {
	data, err := Database.CreateDocument(map[string]interface{}{
		"name": "kerem", "type": "tmp",
	})
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Create Document >> %+v", data)
	util.Dumpf("Database Create Document >> doc.ok: %v", data["ok"])
	util.Dumpf("Database Create Document >> doc.id: %s", data["id"])
	util.Dumpf("Database Create Document >> doc.rev: %s", data["rev"])
	// or
	for key, value := range data {
		util.Dumpf("Database Create Document >> doc.%s: %v", key, value)
	}
}
Example #27
0
/**
 * TestViewCleanup
 */
func TestViewCleanup() {
	ok, err := Database.ViewCleanup()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database View Cleanup >> ok: %v", ok)
}
Example #28
0
/**
 * TestGetMissingRevisions
 */
func TestGetMissingRevisions() {
	data, err := Database.GetMissingRevisions(map[string]interface{}{
		"667b0208441066a0954717b50c0008a9": []string{
			"5-dd1a3738fcbd759ed744f7971fe94332",
		},
	})
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Missing Revisions >> %v", data)
	util.Dumpf("Database Missing Revisions >> missing_revs: %v", data["missing_revs"])
	util.Dumpf("Database Missing Revisions >> missing_revs.667b0208441066a0954717b50c0008a9: %s",
		util.Dig("missing_revs.667b0208441066a0954717b50c0008a9", data))
	util.Dumpf("Database Missing Revisions >> missing_revs.0: %s",
		util.Dig("missing_revs.667b0208441066a0954717b50c0008a9.0", data))
}
Example #29
0
/**
 * TestSetRevisionLimit
 */
func TestSetRevisionLimit() {
	ok, err := Database.SetRevisionLimit(1000)
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Set Revision Limit >> ok: %v", ok)
}
Example #30
0
/**
 * TestGetRevisionLimit
 */
func TestGetRevisionLimit() {
	data, err := Database.GetRevisionLimit()
	if err != nil {
		panic(err)
	}
	util.Dumpf("Database Get Revision Limit >> %d", data)
}