@@ -25,11 +25,11 @@ func writeToTestFile(t testing.TB, fileName string, content []byte) string {
2525}
2626
2727func Test_FileIngestOptions_FileOptions (t * testing.T ) {
28- t .Run ("with mapping" , func (t * testing.T ) {
28+ t .Run ("with mapping" , func (t * testing.T ) {
2929 mappingFile := writeToTestFile (t , "test-mapping.json" , []byte (`[]` ))
3030
3131 options := FileIngestOptions {
32- Format : "csv" ,
32+ Format : "csv" ,
3333 MappingsFile : mappingFile ,
3434 }
3535
@@ -40,15 +40,15 @@ func Test_FileIngestOptions_FileOptions(t *testing.T) {
4040
4141 t .Run ("with invalid mapping file" , func (t * testing.T ) {
4242 options := FileIngestOptions {
43- Format : "csv" ,
43+ Format : "csv" ,
4444 MappingsFile : "some-random-file" ,
4545 }
4646
4747 _ , err := options .FileOptions ()
4848 assert .Error (t , err )
4949 })
5050
51- t .Run ("without mapping" , func (t * testing.T ) {
51+ t .Run ("without mapping" , func (t * testing.T ) {
5252 options := FileIngestOptions {
5353 Format : "csv" ,
5454 }
@@ -61,7 +61,7 @@ func Test_FileIngestOptions_FileOptions(t *testing.T) {
6161
6262func Test_FileIngestOptions_Run_IngestFile_NoMapping (t * testing.T ) {
6363 sourceFile := writeToTestFile (t , "logs.json" , []byte ("{}" ))
64-
64+
6565 cli := testingcli .New ()
6666
6767 ingestor := testingkusto .New (func (ing * testingkusto.Ingestor ) {
@@ -74,9 +74,9 @@ func Test_FileIngestOptions_Run_IngestFile_NoMapping(t *testing.T) {
7474 })
7575
7676 opts := FileIngestOptions {
77- SourceFile : sourceFile ,
78- Format : "multijson" ,
79- Auth : newTestAuth (),
77+ SourceFile : sourceFile ,
78+ Format : "multijson" ,
79+ Auth : newTestAuth (),
8080 KustoTarget : newTestKustoTarget (),
8181
8282 ingestorBuildSettings : ingestorBuildSettings {
@@ -93,7 +93,7 @@ func Test_FileIngestOptions_Run_IngestFile_NoMapping(t *testing.T) {
9393func Test_FileIngestOptions_Run_IngestFile_WithMapping (t * testing.T ) {
9494 sourceFile := writeToTestFile (t , "logs.json" , []byte ("{}" ))
9595 sourceFileMapping := writeToTestFile (t , "logs-mapping.json" , []byte ("[]" ))
96-
96+
9797 cli := testingcli .New ()
9898
9999 ingestor := testingkusto .New (func (ing * testingkusto.Ingestor ) {
@@ -106,11 +106,11 @@ func Test_FileIngestOptions_Run_IngestFile_WithMapping(t *testing.T) {
106106 })
107107
108108 opts := FileIngestOptions {
109- SourceFile : sourceFile ,
110- Format : "multijson" ,
109+ SourceFile : sourceFile ,
110+ Format : "multijson" ,
111111 MappingsFile : sourceFileMapping ,
112- Auth : newTestAuth (),
113- KustoTarget : newTestKustoTarget (),
112+ Auth : newTestAuth (),
113+ KustoTarget : newTestKustoTarget (),
114114
115115 ingestorBuildSettings : ingestorBuildSettings {
116116 CreateIngestor : func (target KustoTargetOptions , auth AuthOptions ) (ingest.Ingestor , error ) {
@@ -121,4 +121,25 @@ func Test_FileIngestOptions_Run_IngestFile_WithMapping(t *testing.T) {
121121
122122 err := opts .Run (cli )
123123 assert .NoError (t , err )
124- }
124+ }
125+
126+ func Test_FileIngestOptions_Run_CreateIngestorError (t * testing.T ) {
127+ sourceFile := writeToTestFile (t , "logs.json" , []byte ("{}" ))
128+ cli := testingcli .New ()
129+
130+ opts := FileIngestOptions {
131+ SourceFile : sourceFile ,
132+ Format : "multijson" ,
133+ Auth : newTestAuth (),
134+ KustoTarget : newTestKustoTarget (),
135+ ingestorBuildSettings : ingestorBuildSettings {
136+ CreateIngestor : func (target KustoTargetOptions , auth AuthOptions ) (ingest.Ingestor , error ) {
137+ return nil , assert .AnError
138+ },
139+ },
140+ }
141+
142+ err := opts .Run (cli )
143+ assert .Error (t , err )
144+ assert .Contains (t , err .Error (), "create Kusto ingestor" )
145+ }
0 commit comments