github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/syz-cluster/pkg/blob/storage_test.go (about) 1 // Copyright 2024 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package blob 5 6 import ( 7 "bytes" 8 "fmt" 9 "testing" 10 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func TestLocalStorage(t *testing.T) { 15 storage := NewLocalStorage(t.TempDir()) 16 var uris []string 17 for i := 0; i < 2; i++ { 18 content := fmt.Sprintf("object #%d", i) 19 uri, err := storage.Write(bytes.NewReader([]byte(content)), fmt.Sprint(i)) 20 assert.NoError(t, err) 21 uris = append(uris, uri) 22 } 23 for i, uri := range uris { 24 readBytes, err := ReadAllBytes(storage, uri) 25 assert.NoError(t, err) 26 assert.EqualValues(t, fmt.Sprintf("object #%d", i), readBytes) 27 } 28 _, err := storage.Read(localStoragePrefix + "abcdef") 29 assert.Error(t, err) 30 _, err = storage.Read("abcdef") 31 assert.Error(t, err) 32 }