-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* getOperatorsAvsState test read input from json * parse test output from json * add json path as a test parameter * rename json pubkey * add test data path as env variable * remove output data from json * delete json file * move test to compliance folder * revert changes on chaincaller tests * add json in put to bls_agg test * refactor default inputs * add json input to TestEgnAddrsWithServiceManagerFlag
- Loading branch information
1 parent
cd86e21
commit 1b92e0f
Showing
4 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package testutils | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"os" | ||
) | ||
|
||
// Test data for generic loading of JSON data files. | ||
type TestData[T any] struct { | ||
Input T `json:"input"` | ||
} | ||
|
||
// Create a new instance of `TestData` with the given input data. | ||
func NewTestData[T any](defaultInput T) TestData[T] { | ||
path, exists := os.LookupEnv("TEST_DATA_PATH") | ||
if exists { | ||
file, err := os.ReadFile(path) | ||
if err != nil { | ||
log.Fatalf("Failed to open file: %v", err) | ||
} | ||
|
||
var testData TestData[T] | ||
err = json.Unmarshal(file, &testData) | ||
if err != nil { | ||
log.Fatalf("Failed to decode JSON: %v", err) | ||
} | ||
return testData | ||
} | ||
return TestData[T]{Input: defaultInput} | ||
} |