Beispiel #1
0
func TestWriteWrongTypeRef(t *testing.T) {
	assert := assert.New(t)
	cs := chunks.NewTestStore()
	ds := NewDataStore(cs)

	b := types.Bool(true)
	assert.NotEqual(ref.Ref{}, ds.WriteValue(b))

	assert.Panics(func() { ds.WriteValue(types.NewRefOfBlob(b.Ref())) })
}
Beispiel #2
0
func TestReadValueTypeRefPanics_BUG1121(t *testing.T) {
	assert := assert.New(t)
	cs := chunks.NewTestStore()
	ds := NewDataStore(cs)

	b := types.NewEmptyBlob()
	assert.NotEqual(ref.Ref{}, ds.WriteValue(b))

	datasetID := "ds1"
	aCommit := NewCommit().SetValue(types.NewRef(b.Ref()))
	ds2, err := ds.Commit(datasetID, aCommit)
	assert.NoError(err)

	_, ok := ds2.MaybeHead(datasetID)
	assert.True(ok)
	// Fix BUG 1121 and then uncomment this line and delete the one after
	// assert.NotPanics(func() { ds2.WriteValue(types.NewRefOfBlob(b.Ref())) })
	assert.Panics(func() { ds2.WriteValue(types.NewRefOfBlob(b.Ref())) })
}