Simplify NewMapper by using mapping lists instead of configuration files
diff --git a/cmd/termmapper/fuzz_test.go b/cmd/termmapper/fuzz_test.go
index 8d63d53..e5dd7a5 100644
--- a/cmd/termmapper/fuzz_test.go
+++ b/cmd/termmapper/fuzz_test.go
@@ -8,11 +8,10 @@
"net/http"
"net/http/httptest"
"net/url"
- "os"
- "path/filepath"
"strings"
"testing"
+ tmconfig "github.com/KorAP/KoralPipe-TermMapper/config"
"github.com/KorAP/KoralPipe-TermMapper/mapper"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
@@ -31,26 +30,21 @@
}
func FuzzTransformEndpoint(f *testing.F) {
- // Create a temporary config file with valid mappings
- tmpDir := f.TempDir()
- configFile := filepath.Join(tmpDir, "test-config.yaml")
-
- configContent := `- id: test-mapper
- foundryA: opennlp
- layerA: p
- foundryB: upos
- layerB: p
- mappings:
- - "[PIDAT] <> [opennlp/p=PIDAT & opennlp/p=AdjType:Pdt]"
- - "[DET] <> [opennlp/p=DET]"`
-
- err := os.WriteFile(configFile, []byte(configContent), 0644)
- if err != nil {
- f.Fatal(err)
+ // Create test mapping list
+ mappingList := tmconfig.MappingList{
+ ID: "test-mapper",
+ FoundryA: "opennlp",
+ LayerA: "p",
+ FoundryB: "upos",
+ LayerB: "p",
+ Mappings: []tmconfig.MappingRule{
+ "[PIDAT] <> [opennlp/p=PIDAT & opennlp/p=AdjType:Pdt]",
+ "[DET] <> [opennlp/p=DET]",
+ },
}
// Create mapper
- m, err := mapper.NewMapper(configFile)
+ m, err := mapper.NewMapper([]tmconfig.MappingList{mappingList})
if err != nil {
f.Fatal(err)
}
@@ -141,19 +135,16 @@
}
func TestLargeInput(t *testing.T) {
- // Create a temporary config file
- tmpDir := t.TempDir()
- configFile := filepath.Join(tmpDir, "test-config.yaml")
-
- configContent := `- id: test-mapper
- mappings:
- - "[A] <> [B]"`
-
- err := os.WriteFile(configFile, []byte(configContent), 0644)
- require.NoError(t, err)
+ // Create test mapping list
+ mappingList := tmconfig.MappingList{
+ ID: "test-mapper",
+ Mappings: []tmconfig.MappingRule{
+ "[A] <> [B]",
+ },
+ }
// Create mapper
- m, err := mapper.NewMapper(configFile)
+ m, err := mapper.NewMapper([]tmconfig.MappingList{mappingList})
require.NoError(t, err)
// Create fiber app