本文整理汇总了Golang中github.com/attic-labs/testify/assert.NoError函数的典型用法代码示例。如果您正苦于以下问题:Golang NoError函数的具体用法?Golang NoError怎么用?Golang NoError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NoError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestLDBDataset
func TestLDBDataset(t *testing.T) {
assert := assert.New(t)
dir, err := ioutil.TempDir(os.TempDir(), "")
assert.NoError(err)
ldbPath := path.Join(dir, "name")
cs := chunks.NewLevelDBStoreUseFlags(ldbPath, "")
ds := datas.NewDatabase(cs)
id := "dsName"
set := dataset.NewDataset(ds, id)
commit := types.String("Commit Value")
set, err = set.Commit(commit)
assert.NoError(err)
ds.Close()
spec := fmt.Sprintf("ldb:%s::%s", ldbPath, id)
sp, err := ParseDatasetSpec(spec)
assert.NoError(err)
dataset, err := sp.Dataset()
assert.NoError(err)
assert.EqualValues(commit, dataset.HeadValue())
os.Remove(dir)
}
开发者ID:willhite,项目名称:noms-old,代码行数:25,代码来源:dataspec_test.go
示例2: TestReadRef
func TestReadRef(t *testing.T) {
assert := assert.New(t)
dir, err := ioutil.TempDir(os.TempDir(), "")
assert.NoError(err)
datasetId := "dsName"
ldbPath := path.Join(dir, "/name")
cs1 := chunks.NewLevelDBStoreUseFlags(ldbPath, "")
database1 := datas.NewDatabase(cs1)
dataset1 := dataset.NewDataset(database1, datasetId)
commit := types.String("Commit Value")
dataset1, err = dataset1.Commit(commit)
assert.NoError(err)
r1 := dataset1.Head().Hash()
dataset1.Database().Close()
spec2 := fmt.Sprintf("ldb:%s::%s", ldbPath, r1.String())
sp2, err := ParsePathSpec(spec2)
assert.NoError(err)
database, v2, err := sp2.Value()
assert.NoError(err)
assert.EqualValues(r1.String(), v2.Hash().String())
database.Close()
}
开发者ID:willhite,项目名称:noms-old,代码行数:26,代码来源:dataspec_test.go
示例3: TestLDBDatabase
func TestLDBDatabase(t *testing.T) {
assert := assert.New(t)
d1 := os.TempDir()
dir, err := ioutil.TempDir(d1, "flags")
assert.NoError(err)
ldbDir := path.Join(dir, "store")
spec := fmt.Sprintf("ldb:%s", path.Join(dir, "store"))
cs := chunks.NewLevelDBStoreUseFlags(ldbDir, "")
ds := datas.NewDatabase(cs)
s1 := types.String("A String")
s1Ref := ds.WriteValue(s1)
ds.Commit("testDs", datas.NewCommit().Set(datas.ValueField, s1Ref))
ds.Close()
sp, errRead := ParseDatabaseSpec(spec)
assert.NoError(errRead)
store, err := sp.Database()
assert.NoError(err)
assert.Equal(s1, store.ReadValue(s1.Hash()))
store.Close()
os.Remove(dir)
}
开发者ID:willhite,项目名称:noms-old,代码行数:25,代码来源:dataspec_test.go
示例4: TestTwoClientsWithEmptyDataset
func TestTwoClientsWithEmptyDataset(t *testing.T) {
assert := assert.New(t)
id1 := "testdataset"
cs := chunks.NewMemoryStore()
dsx := newDS(id1, cs)
dsy := newDS(id1, cs)
// dsx: || -> |a|
a := types.String("a")
dsx, err := dsx.CommitValue(a)
assert.NoError(err)
assert.True(dsx.Head().Get(datas.ValueField).Equals(a))
// dsy: || -> |b|
_, ok := dsy.MaybeHead()
assert.False(ok)
b := types.String("b")
dsy, err = dsy.CommitValue(b)
assert.Error(err)
// Commit failed, but ds1 now has latest head, so we should be able to just try again.
// dsy: |a| -> |b|
dsy, err = dsy.CommitValue(b)
assert.NoError(err)
assert.True(dsy.Head().Get(datas.ValueField).Equals(b))
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:dataset_test.go
示例5: TestConstructQueryString
func TestConstructQueryString(t *testing.T) {
assert := assert.New(t)
prefix := "TestConstructQueryString"
d1, e1 := ioutil.TempDir(os.TempDir(), prefix)
defer os.RemoveAll(d1)
d2, e2 := ioutil.TempDir(os.TempDir(), prefix)
defer os.RemoveAll(d2)
assert.NoError(e1)
assert.NoError(e2)
qs, stores := constructQueryString([]string{
"foo=bar",
"store1=ldb:" + d1,
"store2=ldb:" + d2,
"store3=ldb:" + d1,
"hello=world",
})
assert.Equal(5, len(qs))
assert.Equal("bar", qs.Get("foo"))
assert.True(strings.HasPrefix(qs.Get("store1"), dsPathPrefix))
assert.True(strings.HasPrefix(qs.Get("store2"), dsPathPrefix))
assert.True(strings.HasPrefix(qs.Get("store3"), dsPathPrefix))
assert.Equal(qs.Get("store1"), qs.Get("store3"))
assert.NotEqual(qs.Get("store1"), qs.Get("store2"))
assert.Equal(2, len(stores))
}
开发者ID:Richardphp,项目名称:noms,代码行数:29,代码来源:noms_ui_test.go
示例6: TestLDBObject
func TestLDBObject(t *testing.T) {
assert := assert.New(t)
dir, err := ioutil.TempDir(os.TempDir(), "")
assert.NoError(err)
ldbpath := path.Join(dir, "xx-yy")
dsId := "dsId"
cs1 := chunks.NewLevelDBStoreUseFlags(ldbpath, "")
store1 := datas.NewDatabase(cs1)
dataset1 := dataset.NewDataset(store1, dsId)
s1 := types.String("Commit Value")
r1 := store1.WriteValue(s1)
_, err = dataset1.Commit(r1)
assert.NoError(err)
store1.Close()
spec2 := fmt.Sprintf("ldb:%s::%s", ldbpath, dsId)
assert.NoError(err)
sp1, err := ParseDatasetSpec(spec2)
assert.NoError(err)
dataset2, err := sp1.Dataset()
assert.NoError(err)
r2 := dataset2.HeadValue()
s2 := r2.(types.Ref).TargetValue(dataset2.Database())
assert.Equal(s1, s2)
dataset2.Database().Close()
spec3 := fmt.Sprintf("ldb:%s::%s", ldbpath, s1.Hash().String())
sp3, err := ParsePathSpec(spec3)
database, v3, err := sp3.Value()
assert.Equal(s1, v3)
database.Close()
}
开发者ID:willhite,项目名称:noms-old,代码行数:33,代码来源:dataspec_test.go
示例7: TestPathSpec
func TestPathSpec(t *testing.T) {
assert := assert.New(t)
badSpecs := []string{"mem::#", "mem::#s", "mem::#foobarbaz", "mem::#wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"}
for _, bs := range badSpecs {
_, err := parsePathSpec(bs)
assert.Error(err)
}
type testCase struct {
spec, scheme, dbPath, pathStr string
}
testCases := []testCase{
testCase{"http://local.attic.io/john/doe::#0123456789abcdefghijklmnopqrstuv", "http", "//local.attic.io/john/doe", "#0123456789abcdefghijklmnopqrstuv"},
testCase{"ldb:/filesys/john/doe::#0123456789abcdefghijklmnopqrstuv", "ldb", "/filesys/john/doe", "#0123456789abcdefghijklmnopqrstuv"},
testCase{"mem::#0123456789abcdefghijklmnopqrstuv", "mem", "", "#0123456789abcdefghijklmnopqrstuv"},
testCase{"http://local.attic.io/john/doe::#0123456789abcdefghijklmnopqrstuv", "http", "//local.attic.io/john/doe", "#0123456789abcdefghijklmnopqrstuv"},
testCase{"http://localhost:8000/john/doe/::ds1", "http", "//localhost:8000/john/doe/", "ds1"},
}
for _, tc := range testCases {
dbSpec := databaseSpec{Protocol: tc.scheme, Path: tc.dbPath, accessToken: ""}
path, err := NewAbsolutePath(tc.pathStr)
assert.NoError(err)
expected := pathSpec{dbSpec, path}
actual, err := parsePathSpec(tc.spec)
assert.NoError(err)
assert.Equal(expected, actual)
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:31,代码来源:dataspec_test.go
示例8: TestWriteValue
func TestWriteValue(t *testing.T) {
assert := assert.New(t)
factory := chunks.NewMemoryStoreFactory()
defer factory.Shutter()
router = setupWebServer(factory)
defer func() { router = nil }()
testString := "Now, what?"
authKey = "anauthkeyvalue"
w := httptest.NewRecorder()
r, err := newRequest("GET", dbName+constants.RootPath, nil)
assert.NoError(err)
router.ServeHTTP(w, r)
lastRoot := w.Body
assert.Equal(http.StatusOK, w.Code)
tval := types.Bool(true)
wval := types.String(testString)
chunk1 := types.EncodeValue(tval, nil)
chunk2 := types.EncodeValue(wval, nil)
refList := types.NewList(types.NewRef(tval), types.NewRef(wval))
chunk3 := types.EncodeValue(refList, nil)
body := &bytes.Buffer{}
// we would use this func, but it's private so use next line instead: serializeHints(body, map[ref.Ref]struct{}{hint: struct{}{}})
err = binary.Write(body, binary.BigEndian, uint32(0))
assert.NoError(err)
chunks.Serialize(chunk1, body)
chunks.Serialize(chunk2, body)
chunks.Serialize(chunk3, body)
w = httptest.NewRecorder()
r, err = newRequest("POST", dbName+constants.WriteValuePath+"?access_token="+authKey, ioutil.NopCloser(body))
assert.NoError(err)
router.ServeHTTP(w, r)
assert.Equal(http.StatusCreated, w.Code)
w = httptest.NewRecorder()
args := fmt.Sprintf("&last=%s¤t=%s", lastRoot, types.NewRef(refList).TargetHash())
r, _ = newRequest("POST", dbName+constants.RootPath+"?access_token="+authKey+args, ioutil.NopCloser(body))
router.ServeHTTP(w, r)
assert.Equal(http.StatusOK, w.Code)
whash := wval.Hash()
hints := map[hash.Hash]struct{}{whash: struct{}{}}
rdr := buildGetRefsRequestBody(hints)
r, _ = newRequest("POST", dbName+constants.GetRefsPath, rdr)
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
router.ServeHTTP(w, r)
assert.Equal(http.StatusOK, w.Code)
ms := chunks.NewMemoryStore()
chunks.Deserialize(w.Body, ms, nil)
v := types.DecodeValue(ms.Get(whash), datas.NewDatabase(ms))
assert.Equal(testString, string(v.(types.String)))
}
开发者ID:kalman,项目名称:noms-pre-release,代码行数:59,代码来源:web_server_test.go
示例9: TestChunkWriteAfterCloseFails
func TestChunkWriteAfterCloseFails(t *testing.T) {
assert := assert.New(t)
input := "abc"
w := NewChunkWriter()
_, err := w.Write([]byte(input))
assert.NoError(err)
assert.NoError(w.Close())
assert.Panics(func() { w.Write([]byte(input)) }, "Write() after Close() should barf!")
}
开发者ID:willhite,项目名称:noms-old,代码行数:10,代码来源:chunk_test.go
示例10: TestMemDatabase
func TestMemDatabase(t *testing.T) {
assert := assert.New(t)
spec := "mem"
sp, err := ParseDatabaseSpec(spec)
assert.NoError(err)
store, err := sp.Database()
assert.NoError(err)
r := store.WriteValue(types.Bool(true))
assert.NoError(err)
assert.Equal(types.Bool(true), store.ReadValue(r.TargetHash()))
}
开发者ID:willhite,项目名称:noms-old,代码行数:13,代码来源:dataspec_test.go
示例11: TestMemDataset
func TestMemDataset(t *testing.T) {
assert := assert.New(t)
spec := "mem::datasetTest"
sp1, err := ParseDatasetSpec(spec)
assert.NoError(err)
dataset1, err := sp1.Dataset()
assert.NoError(err)
commit := types.String("Commit Value")
dsTest, err := dataset1.Commit(commit)
assert.NoError(err)
assert.EqualValues(commit, dsTest.HeadValue())
}
开发者ID:willhite,项目名称:noms-old,代码行数:13,代码来源:dataspec_test.go
示例12: TestReadBigEndianIntegers
func TestReadBigEndianIntegers(t *testing.T) {
assert := assert.New(t)
buf := &bytes.Buffer{}
err := binary.Write(buf, binary.BigEndian, uint32(1))
assert.NoError(err)
err = binary.Write(buf, binary.BigEndian, uint64(1))
assert.NoError(err)
r := binaryNomsReader{buf.Bytes(), 0}
assert.True(r.readUint32() == uint32(1))
assert.True(r.readUint64() == uint64(1))
}
开发者ID:Richardphp,项目名称:noms,代码行数:13,代码来源:codec_test.go
示例13: TestAbsolutePaths
func TestAbsolutePaths(t *testing.T) {
assert := assert.New(t)
s0, s1 := types.String("foo"), types.String("bar")
list := types.NewList(s0, s1)
emptySet := types.NewSet()
db := datas.NewDatabase(chunks.NewMemoryStore())
db.WriteValue(s0)
db.WriteValue(s1)
db.WriteValue(list)
db.WriteValue(emptySet)
var err error
db, err = db.Commit("ds", datas.NewCommit(list, types.NewSet(), types.EmptyStruct))
assert.NoError(err)
head := db.Head("ds")
resolvesTo := func(exp types.Value, str string) {
p, err := NewAbsolutePath(str)
assert.NoError(err)
act := p.Resolve(db)
if exp == nil {
assert.Nil(act)
} else {
assert.True(exp.Equals(act), "%s Expected %s Actual %s", str, types.EncodedValue(exp), types.EncodedValue(act))
}
}
resolvesTo(head, "ds")
resolvesTo(emptySet, "ds.parents")
resolvesTo(list, "ds.value")
resolvesTo(s0, "ds.value[0]")
resolvesTo(s1, "ds.value[1]")
resolvesTo(head, "#"+head.Hash().String())
resolvesTo(list, "#"+list.Hash().String())
resolvesTo(s0, "#"+s0.Hash().String())
resolvesTo(s1, "#"+s1.Hash().String())
resolvesTo(s0, "#"+list.Hash().String()+"[0]")
resolvesTo(s1, "#"+list.Hash().String()+"[1]")
resolvesTo(nil, "foo")
resolvesTo(nil, "foo.parents")
resolvesTo(nil, "foo.value")
resolvesTo(nil, "foo.value[0]")
resolvesTo(nil, "#"+types.String("baz").Hash().String())
resolvesTo(nil, "#"+types.String("baz").Hash().String()+"[0]")
}
开发者ID:Richardphp,项目名称:noms,代码行数:48,代码来源:absolute_path_test.go
示例14: TestDatabaseSpecs
func TestDatabaseSpecs(t *testing.T) {
assert := assert.New(t)
badSpecs := []string{"mem:stuff", "mem:", "http:", "https:", "random:", "random:random", "/file/ba:d"}
for _, spec := range badSpecs {
_, err := parseDatabaseSpec(spec)
assert.Error(err, spec)
}
type testCase struct {
spec, scheme, path, accessToken string
}
testCases := []testCase{
testCase{"http://localhost:8000", "http", "//localhost:8000", ""},
testCase{"http://localhost:8000/fff", "http", "//localhost:8000/fff", ""},
testCase{"https://local.attic.io/john/doe", "https", "//local.attic.io/john/doe", ""},
testCase{"ldb:/filesys/john/doe", "ldb", "/filesys/john/doe", ""},
testCase{"./john/doe", "ldb", "./john/doe", ""},
testCase{"john/doe", "ldb", "john/doe", ""},
testCase{"/john/doe", "ldb", "/john/doe", ""},
testCase{"mem", "mem", "", ""},
testCase{"http://server.com/john/doe?access_token=jane", "http", "//server.com/john/doe?access_token=jane", "jane"},
testCase{"https://server.com/john/doe/?arg=2&qp1=true&access_token=jane", "https", "//server.com/john/doe/?arg=2&qp1=true&access_token=jane", "jane"},
}
for _, tc := range testCases {
dbSpec, err := parseDatabaseSpec(tc.spec)
assert.NoError(err)
assert.Equal(databaseSpec{Protocol: tc.scheme, Path: tc.path, accessToken: tc.accessToken}, dbSpec)
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:32,代码来源:dataspec_test.go
示例15: TestHeadValueFunctions
func TestHeadValueFunctions(t *testing.T) {
assert := assert.New(t)
id1 := "testdataset"
id2 := "otherdataset"
cs := chunks.NewMemoryStore()
ds1 := newDS(id1, cs)
// ds1: |a|
a := types.String("a")
ds1, err := ds1.CommitValue(a)
assert.NoError(err)
hv := ds1.Head().Get(datas.ValueField)
assert.Equal(a, hv)
assert.Equal(a, ds1.HeadValue())
hv, ok := ds1.MaybeHeadValue()
assert.True(ok)
assert.Equal(a, hv)
ds2 := newDS(id2, cs)
assert.Panics(func() {
ds2.HeadValue()
})
_, ok = ds2.MaybeHeadValue()
assert.False(ok)
}
开发者ID:Richardphp,项目名称:noms,代码行数:29,代码来源:dataset_test.go
示例16: TestPathParseSuccess
func TestPathParseSuccess(t *testing.T) {
assert := assert.New(t)
test := func(str string, expectPath Path) {
p, err := NewPath().AddPath(str)
assert.NoError(err)
assert.Equal(expectPath, p)
}
test(".foo", NewPath().AddField("foo"))
test(".Q", NewPath().AddField("Q"))
test(".QQ", NewPath().AddField("QQ"))
test("[true]", NewPath().AddIndex(Bool(true)))
test("[false]", NewPath().AddIndex(Bool(false)))
test("[42]", NewPath().AddIndex(Number(42)))
test("[1e4]", NewPath().AddIndex(Number(1e4)))
test("[1.]", NewPath().AddIndex(Number(1.)))
test("[1.345]", NewPath().AddIndex(Number(1.345)))
test(`[""]`, NewPath().AddIndex(String("")))
test(`["42"]`, NewPath().AddIndex(String("42")))
test("[\"line\nbreak\rreturn\"]", NewPath().AddIndex(String("line\nbreak\rreturn")))
test(`["qu\\ote\""]`, NewPath().AddIndex(String(`qu\ote"`)))
test(`["π"]`, NewPath().AddIndex(String("π")))
test(`["[[br][]acke]]ts"]`, NewPath().AddIndex(String("[[br][]acke]]ts")))
test(`["xπy✌z"]`, NewPath().AddIndex(String("xπy✌z")))
test(`["ಠ_ಠ"]`, NewPath().AddIndex(String("ಠ_ಠ")))
}
开发者ID:willhite,项目名称:noms-old,代码行数:27,代码来源:path_test.go
示例17: TestHandleGetRefs
func TestHandleGetRefs(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
input1, input2 := "abc", "def"
chnx := []chunks.Chunk{
chunks.NewChunk([]byte(input1)),
chunks.NewChunk([]byte(input2)),
}
err := cs.PutMany(chnx)
assert.NoError(err)
body := strings.NewReader(fmt.Sprintf("ref=%s&ref=%s", chnx[0].Hash(), chnx[1].Hash()))
w := httptest.NewRecorder()
HandleGetRefs(w,
&http.Request{Body: ioutil.NopCloser(body), Method: "POST", Header: http.Header{
"Content-Type": {"application/x-www-form-urlencoded"},
}},
params{},
cs,
)
if assert.Equal(http.StatusOK, w.Code, "Handler error:\n%s", string(w.Body.Bytes())) {
chunkChan := make(chan *chunks.Chunk)
go chunks.DeserializeToChan(w.Body, chunkChan)
for c := range chunkChan {
assert.Equal(chnx[0].Hash(), c.Hash())
chnx = chnx[1:]
}
assert.Empty(chnx)
}
}
开发者ID:willhite,项目名称:noms-old,代码行数:32,代码来源:remote_database_handlers_test.go
示例18: TestHandlePostRoot
func TestHandlePostRoot(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
input1, input2 := "abc", "def"
chnx := []chunks.Chunk{
chunks.NewChunk([]byte(input1)),
chunks.NewChunk([]byte(input2)),
}
err := cs.PutMany(chnx)
assert.NoError(err)
// First attempt should fail, as 'last' won't match.
u := &url.URL{}
queryParams := url.Values{}
queryParams.Add("last", chnx[0].Hash().String())
queryParams.Add("current", chnx[1].Hash().String())
u.RawQuery = queryParams.Encode()
w := httptest.NewRecorder()
HandleRootPost(w, &http.Request{URL: u, Method: "POST"}, params{}, cs)
assert.Equal(http.StatusConflict, w.Code, "Handler error:\n%s", string(w.Body.Bytes()))
// Now, update the root manually to 'last' and try again.
assert.True(cs.UpdateRoot(chnx[0].Hash(), hash.Hash{}))
w = httptest.NewRecorder()
HandleRootPost(w, &http.Request{URL: u, Method: "POST"}, params{}, cs)
assert.Equal(http.StatusOK, w.Code, "Handler error:\n%s", string(w.Body.Bytes()))
}
开发者ID:willhite,项目名称:noms-old,代码行数:28,代码来源:remote_database_handlers_test.go
示例19: TestHandlePostRoot
func TestHandlePostRoot(t *testing.T) {
assert := assert.New(t)
cs := chunks.NewTestStore()
vs := types.NewValueStore(types.NewBatchStoreAdaptor(cs))
commit := NewCommit(types.String("head"), types.NewSet(), types.NewStruct("Meta", types.StructData{}))
newHead := types.NewMap(types.String("dataset1"), vs.WriteValue(commit))
chnx := []chunks.Chunk{
chunks.NewChunk([]byte("abc")),
types.EncodeValue(newHead, nil),
}
err := cs.PutMany(chnx)
assert.NoError(err)
// First attempt should fail, as 'last' won't match.
u := &url.URL{}
queryParams := url.Values{}
queryParams.Add("last", chnx[0].Hash().String())
queryParams.Add("current", chnx[1].Hash().String())
u.RawQuery = queryParams.Encode()
url := u.String()
w := httptest.NewRecorder()
HandleRootPost(w, newRequest("POST", "", url, nil, nil), params{}, cs)
assert.Equal(http.StatusConflict, w.Code, "Handler error:\n%s", string(w.Body.Bytes()))
// Now, update the root manually to 'last' and try again.
assert.True(cs.UpdateRoot(chnx[0].Hash(), hash.Hash{}))
w = httptest.NewRecorder()
HandleRootPost(w, newRequest("POST", "", url, nil, nil), params{}, cs)
assert.Equal(http.StatusOK, w.Code, "Handler error:\n%s", string(w.Body.Bytes()))
}
开发者ID:Richardphp,项目名称:noms,代码行数:32,代码来源:remote_database_handlers_test.go
示例20: TestDatabaseSpecs
func TestDatabaseSpecs(t *testing.T) {
assert := assert.New(t)
badSpecs := []string{"mem:stuff", "mem:", "http:", "https:", "random:", "random:random", "http://some.com/wi::rd/path", "/file/ba:d"}
for _, spec := range badSpecs {
_, err := ParseDatabaseSpec(spec)
assert.Error(err)
}
testCases := []map[string]string{
map[string]string{"spec": "http://localhost:8000", "scheme": "http", "path": "//localhost:8000"},
map[string]string{"spec": "http://localhost:8000/fff", "scheme": "http", "path": "//localhost:8000/fff"},
map[string]string{"spec": "https://local.attic.io/john/doe", "scheme": "https", "path": "//local.attic.io/john/doe"},
map[string]string{"spec": "ldb:/filesys/john/doe", "scheme": "ldb", "path": "/filesys/john/doe"},
map[string]string{"spec": "./john/doe", "scheme": "ldb", "path": "./john/doe"},
map[string]string{"spec": "john/doe", "scheme": "ldb", "path": "john/doe"},
map[string]string{"spec": "/john/doe", "scheme": "ldb", "path": "/john/doe"},
map[string]string{"spec": "mem", "scheme": "mem", "path": ""},
map[string]string{"spec": "http://server.com/john/doe?access_token=jane", "scheme": "http", "path": "//server.com/john/doe?access_token=jane", "accessToken": "jane"},
map[string]string{"spec": "https://server.com/john/doe/?arg=2&qp1=true&access_token=jane", "scheme": "https", "path": "//server.com/john/doe/?arg=2&qp1=true&access_token=jane", "accessToken": "jane"},
}
for _, tc := range testCases {
dbSpec, err := ParseDatabaseSpec(tc["spec"])
assert.NoError(err)
assert.Equal(DatabaseSpec{Protocol: tc["scheme"], Path: tc["path"], accessToken: tc["accessToken"]}, dbSpec)
}
}
开发者ID:willhite,项目名称:noms-old,代码行数:28,代码来源:dataspec_test.go
注:本文中的github.com/attic-labs/testify/assert.NoError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论