Skip to content

Commit

Permalink
test - test Put with -1 as size
Browse files Browse the repository at this point in the history
Show that all backends can receive -1 as size for Put.
  • Loading branch information
urisimchoni committed Jul 7, 2019
1 parent 7fb22cf commit dbc7963
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ func All(t *testing.T, kind string, config stow.Config) {
// Tests metadata retrieval on PUTs.
item1Content := "item one"
item1Name := "a_first/the item"
item1, skip1 := putItem(is, c1, item1Name, item1Content, md1)
item1, skip1 := putItem(is, c1, item1Name, item1Content, md1, true)
is.OK(item1)
if !skip1 {
is.NoErr(checkMetadata(t, is, item1, md1))
}

item2, _ := putItem(is, c1, "a_second/the item", "item two", nil)
item2, _ := putItem(is, c1, "a_second/the item", "item two", nil, true)
is.OK(item2)

item3, _ := putItem(is, c1, "the_third/the item", "item three", nil)
item3, _ := putItem(is, c1, "the_third/the item", "item three", nil, false)
is.OK(item3)

defer func() {
Expand Down Expand Up @@ -309,13 +309,17 @@ func createContainer(is is.I, location stow.Location, name string) stow.Containe
return container
}

func putItem(is is.I, container stow.Container, name, content string, md map[string]interface{}) (stow.Item, bool) {
func putItem(is is.I, container stow.Container, name, content string, md map[string]interface{}, knownSize bool) (stow.Item, bool) {
var skipAssertion bool // skip metadata assertion
item, err := container.Put(name, strings.NewReader(content), int64(len(content)), md)
size := int64(len(content))
if !knownSize {
size = int64(-1)
}
item, err := container.Put(name, strings.NewReader(content), size, md)

// Metadata retrieval isn't supported
if stow.IsNotSupported(err) {
item, err = container.Put(name, strings.NewReader(content), int64(len(content)), nil)
item, err = container.Put(name, strings.NewReader(content), size, nil)
skipAssertion = true
}

Expand Down

0 comments on commit dbc7963

Please sign in to comment.