1
1
/*
2
- Copyright 2023-2024 API Testing Authors.
2
+ Copyright 2023-2025 API Testing Authors.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -17,47 +17,68 @@ limitations under the License.
17
17
package runner
18
18
19
19
import (
20
- "testing"
20
+ "testing"
21
21
22
- atest "github.com/linuxsuren/api-testing/pkg/testing"
23
- "github.com/stretchr/testify/assert"
22
+ atest "github.com/linuxsuren/api-testing/pkg/testing"
23
+ "github.com/stretchr/testify/assert"
24
24
)
25
25
26
26
func TestRunnerFactory (t * testing.T ) {
27
- runner := GetTestSuiteRunner (& atest.TestSuite {})
28
- assert .IsType (t , NewSimpleTestCaseRunner (), runner )
27
+ runner := GetTestSuiteRunner (& atest.TestSuite {})
28
+ assert .IsType (t , NewSimpleTestCaseRunner (), runner )
29
29
30
- runner = GetTestSuiteRunner (& atest.TestSuite {Spec : atest.APISpec {Kind : "grpc" , RPC : & atest.RPCDesc {}}})
31
- assert .IsType (t , NewGRPCTestCaseRunner ("" , atest.RPCDesc {}), runner )
30
+ runner = GetTestSuiteRunner (& atest.TestSuite {Spec : atest.APISpec {Kind : "grpc" , RPC : & atest.RPCDesc {}}})
31
+ assert .IsType (t , NewGRPCTestCaseRunner ("" , atest.RPCDesc {}), runner )
32
32
}
33
33
34
34
func TestUnimplementedRunner (t * testing.T ) {
35
- runner := NewDefaultUnimplementedRunner ()
36
- output , err := runner .RunTestCase (& atest.TestCase {}, nil , nil )
37
- assert .Nil (t , output )
38
- assert .Error (t , err )
35
+ runner := NewDefaultUnimplementedRunner ()
36
+ output , err := runner .RunTestCase (& atest.TestCase {}, nil , nil )
37
+ assert .Nil (t , output )
38
+ assert .Error (t , err )
39
39
40
- runner .WithWriteLevel ("debug" )
41
- runner .WithTestReporter (nil )
40
+ runner .WithWriteLevel ("debug" )
41
+ runner .WithTestReporter (nil )
42
42
43
- var results []* atest.TestCase
44
- results , err = runner .GetSuggestedAPIs (nil , "" )
45
- assert .Nil (t , results )
46
- assert .NoError (t , err )
43
+ var results []* atest.TestCase
44
+ results , err = runner .GetSuggestedAPIs (nil , "" )
45
+ assert .Nil (t , results )
46
+ assert .NoError (t , err )
47
47
48
- runner .WithAPISuggestLimit (0 )
48
+ runner .WithAPISuggestLimit (0 )
49
49
}
50
50
51
51
func TestSimpleResponse (t * testing.T ) {
52
- t .Run ("get fileName" , func (t * testing.T ) {
53
- // without filename
54
- assert .Empty (t , SimpleResponse {}.getFileName ())
55
-
56
- // normal case
57
- assert .Equal (t , "a.txt" , SimpleResponse {
58
- Header : map [string ]string {
59
- "Content-Disposition" : `attachment; filename="a.txt"` ,
60
- },
61
- }.getFileName ())
62
- })
52
+ t .Run ("get fileName" , func (t * testing.T ) {
53
+ // without filename
54
+ assert .Empty (t , SimpleResponse {}.getFileName ())
55
+
56
+ // normal case
57
+ assert .Equal (t , "a.txt" , SimpleResponse {
58
+ Header : map [string ]string {
59
+ "Content-Disposition" : `attachment; filename="a.txt"` ,
60
+ },
61
+ }.getFileName ())
62
+
63
+ // without space
64
+ assert .Equal (t , "a.txt" , SimpleResponse {
65
+ Header : map [string ]string {
66
+ "Content-Disposition" : `attachment;filename="a.txt"` ,
67
+ },
68
+ }.getFileName ())
69
+
70
+ // without quote
71
+ assert .Equal (t , "a.txt" , SimpleResponse {
72
+ Header : map [string ]string {
73
+ "Content-Disposition" : `attachment; filename=a.txt` ,
74
+ },
75
+ }.getFileName ())
76
+
77
+ // without quote and space
78
+ assert .Equal (t , "a.txt" , SimpleResponse {
79
+ Header : map [string ]string {
80
+ "Content-Disposition" : `attachment;filename=a.txt` ,
81
+ },
82
+ }.getFileName ())
83
+ })
63
84
}
0 commit comments