MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestGetLineageProvider

Function TestGetLineageProvider

lineage_test.go:31–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestGetLineageProvider(t *testing.T) {
32 datasource, _, err := newTestDataSource()
33 if err != nil {
34 t.Fatalf("Error creating test data source: %s", err)
35 }
36
37 ledgerforge, err := NewLedgerForge(datasource)
38 if err != nil {
39 t.Fatalf("Error creating LedgerForge instance: %s", err)
40 }
41
42 tests := []struct {
43 name string
44 txn *model.Transaction
45 expected string
46 }{
47 {
48 name: "No metadata",
49 txn: &model.Transaction{},
50 expected: "",
51 },
52 {
53 name: "Metadata without provider",
54 txn: &model.Transaction{
55 MetaData: map[string]interface{}{
56 "other_key": "value",
57 },
58 },
59 expected: "",
60 },
61 {
62 name: "Metadata with provider",
63 txn: &model.Transaction{
64 MetaData: map[string]interface{}{
65 "LEDGERFORGE_LINEAGE_PROVIDER": "stripe",
66 },
67 },
68 expected: "stripe",
69 },
70 {
71 name: "Provider with non-string value",
72 txn: &model.Transaction{
73 MetaData: map[string]interface{}{
74 "LEDGERFORGE_LINEAGE_PROVIDER": 123,
75 },
76 },
77 expected: "",
78 },
79 }
80
81 for _, tt := range tests {
82 t.Run(tt.name, func(t *testing.T) {
83 result := ledgerforge.getLineageProvider(tt.txn)
84 assert.Equal(t, tt.expected, result)
85 })
86 }
87}
88

Callers

nothing calls this directly

Calls 3

getLineageProviderMethod · 0.95
newTestDataSourceFunction · 0.85
NewLedgerForgeFunction · 0.85

Tested by

no test coverage detected