Skip to content

Commit

Permalink
Address typo in README and include name in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmm-sumo committed Jun 6, 2021
1 parent c3d7d20 commit ae9cb88
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion extension/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A storage extension persists state beyond the collector process. Other component

The `storage.Extension` interface extends `component.Extension` by adding the following method:
```
GetClient(component.Kind, component.Kind, config.ComponentID, string) (Client, error)
GetClient(context.Context, component.Kind, config.ComponentID, string) (Client, error)
```

The `storage.Client` interface contains the following methods:
Expand Down
40 changes: 40 additions & 0 deletions extension/storage/filestorage/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,46 @@ func TestNewExtensionErrorsOnMissingDirectory(t *testing.T) {
require.Nil(t, extension)
}

func TestTwoClientsWithDifferentNames(t *testing.T) {
ctx := context.Background()
se := newTestExtension(t)

client1, err := se.GetClient(
ctx,
component.KindReceiver,
newTestEntity("my_component"),
"foo",
)
require.NoError(t, err)

client2, err := se.GetClient(
ctx,
component.KindReceiver,
newTestEntity("my_component"),
"bar",
)
require.NoError(t, err)

myBytes1 := []byte("value1")
myBytes2 := []byte("value2")

// Set the data
err = client1.Set(ctx, "key", myBytes1)
require.NoError(t, err)

err = client2.Set(ctx, "key", myBytes2)
require.NoError(t, err)

// Check it was associated accordingly
data, err := client1.Get(ctx, "key")
require.NoError(t, err)
require.Equal(t, myBytes1, data)

data, err = client2.Get(ctx, "key")
require.NoError(t, err)
require.Equal(t, myBytes2, data)
}

func TestGetClientErrorsOnDeletedDirectory(t *testing.T) {
ctx := context.Background()

Expand Down

0 comments on commit ae9cb88

Please sign in to comment.