@@ -30,19 +30,21 @@ func TestScpCache(t *testing.T) {
3030 tests := []struct {
3131 path string
3232 content []byte
33+ ignore bool
3334 }{
34- {"http://Foo.Bar/foo_Bar-Foo" , []byte (`T€st Content 123` )},
35- {"fOO,bar:foo%bAR" , []byte (`T€st Content 123 fOO,bar:foo%bAR` )},
36- {"FOo/BaR.html" , []byte (`FOo/BaR.html T€st Content 123` )},
37- {"трям/трям" , []byte (`T€st трям/трям Content 123` )},
38- {"은행" , []byte (`T€st C은행ontent 123` )},
39- {"Банковский кассир" , []byte (`Банковский кассир T€st Content 123` )},
35+ {"http://Foo.Bar/foo_Bar-Foo" , []byte (`T€st Content 123` ), false },
36+ {"fOO,bar:foo%bAR" , []byte (`T€st Content 123 fOO,bar:foo%bAR` ), false },
37+ {"FOo/BaR.html" , []byte (`FOo/BaR.html T€st Content 123` ), false },
38+ {"трям/трям" , []byte (`T€st трям/трям Content 123` ), false },
39+ {"은행" , []byte (`T€st C은행ontent 123` ), false },
40+ {"Банковский кассир" , []byte (`Банковский кассир T€st Content 123` ), false },
41+ {"Банковский кассир" , []byte (`Банковский кассир T€st Content 456` ), true },
4042 }
4143
4244 fs := new (afero.MemMapFs )
4345
4446 for _ , test := range tests {
45- c , err := resGetCache (test .path , fs )
47+ c , err := resGetCache (test .path , fs , test . ignore )
4648 if err != nil {
4749 t .Errorf ("Error getting cache: %s" , err )
4850 }
@@ -55,12 +57,18 @@ func TestScpCache(t *testing.T) {
5557 t .Errorf ("Error writing cache: %s" , err )
5658 }
5759
58- c , err = resGetCache (test .path , fs )
60+ c , err = resGetCache (test .path , fs , test . ignore )
5961 if err != nil {
6062 t .Errorf ("Error getting cache after writing: %s" , err )
6163 }
62- if bytes .Compare (c , test .content ) != 0 {
63- t .Errorf ("\n Expected: %s\n Actual: %s\n " , string (test .content ), string (c ))
64+ if test .ignore {
65+ if c != nil {
66+ t .Errorf ("Cache ignored but content is not nil: %s" , string (c ))
67+ }
68+ } else {
69+ if bytes .Compare (c , test .content ) != 0 {
70+ t .Errorf ("\n Expected: %s\n Actual: %s\n " , string (test .content ), string (c ))
71+ }
6472 }
6573 }
6674}
@@ -111,10 +119,12 @@ func TestScpGetRemote(t *testing.T) {
111119 tests := []struct {
112120 path string
113121 content []byte
122+ ignore bool
114123 }{
115- {"http://Foo.Bar/foo_Bar-Foo" , []byte (`T€st Content 123` )},
116- {"http://Doppel.Gänger/foo_Bar-Foo" , []byte (`T€st Cont€nt 123` )},
117- {"http://Doppel.Gänger/Fizz_Bazz-Foo" , []byte (`T€st Банковский кассир Cont€nt 123` )},
124+ {"http://Foo.Bar/foo_Bar-Foo" , []byte (`T€st Content 123` ), false },
125+ {"http://Doppel.Gänger/foo_Bar-Foo" , []byte (`T€st Cont€nt 123` ), false },
126+ {"http://Doppel.Gänger/Fizz_Bazz-Foo" , []byte (`T€st Банковский кассир Cont€nt 123` ), false },
127+ {"http://Doppel.Gänger/Fizz_Bazz-Bar" , []byte (`T€st Банковский кассир Cont€nt 456` ), true },
118128 }
119129
120130 for _ , test := range tests {
@@ -131,12 +141,18 @@ func TestScpGetRemote(t *testing.T) {
131141 if bytes .Compare (c , test .content ) != 0 {
132142 t .Errorf ("\n Net Expected: %s\n Net Actual: %s\n " , string (test .content ), string (c ))
133143 }
134- cc , cErr := resGetCache (test .path , fs )
144+ cc , cErr := resGetCache (test .path , fs , test . ignore )
135145 if cErr != nil {
136146 t .Error (cErr )
137147 }
138- if bytes .Compare (cc , test .content ) != 0 {
139- t .Errorf ("\n Cache Expected: %s\n Cache Actual: %s\n " , string (test .content ), string (c ))
148+ if test .ignore {
149+ if cc != nil {
150+ t .Errorf ("Cache ignored but content is not nil: %s" , string (cc ))
151+ }
152+ } else {
153+ if bytes .Compare (cc , test .content ) != 0 {
154+ t .Errorf ("\n Cache Expected: %s\n Cache Actual: %s\n " , string (test .content ), string (cc ))
155+ }
140156 }
141157 }
142158}
0 commit comments