Skip to content

Commit

Permalink
Added readme
Browse files Browse the repository at this point in the history
Signed-off-by: Janos <[email protected]>
  • Loading branch information
Janos committed Aug 12, 2024
1 parent 91fe31e commit 98e173e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,29 @@ func TestMyApplication(t *testing.T) {

your.App(ctx)
}
```
```

## Randomness

The random functions provide a number of randomness sources for testing purposes, some deterministic, some not.

To obtain a deterministic randomness source *tied to a test name*, you can use the `DeterministicSource` (implementing an `io.Reader`) as follows:

```go
package your_test

import (
"testing"
"your"

"github.com/opentofu/tofutestutils"
)

func TestMyApp(t *testing.T) {
randomness := tofutestutils.DeterministicRandomSource(t)

your.App(randomness)
}
```

For a full list of possible functions, please [check the Go docs](https://pkg.go.dev/github.com/opentofu/tofutestutils).
24 changes: 24 additions & 0 deletions testrandom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Randomness sources

This folder contains a number of randomness sources for testing purposes, some deterministic, some not.

To obtain a deterministic randomness source *tied to a test name*, you can use the `DeterministicSource` (implementing an `io.Reader`) as follows:

```go
package your_test

import (
"testing"
"your"

"github.com/opentofu/tofutestutils/testrandom"
)

func TestMyApp(t *testing.T) {
randomness := testrandom.DeterministicSource(t)

your.App(randomness)
}
```

For a full list of possible functions, please [check the Go docs](https://pkg.go.dev/github.com/opentofu/tofutestutils/testrandom).

0 comments on commit 98e173e

Please sign in to comment.