(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestDetectFilename(t *testing.T) { |
| 25 | // Test default / fallback with no file extension |
| 26 | nakedFilename := Config{OutputPath: "test"} |
| 27 | nakedFilename.detectFromFilename() |
| 28 | if nakedFilename.Archive != "tar" { |
| 29 | t.Error("Expected to find tar archive setting") |
| 30 | } |
| 31 | if nakedFilename.Algorithm != "pgzip" { |
| 32 | t.Error("Expected to find pgzip algorithm setting") |
| 33 | } |
| 34 | |
| 35 | // Test .archive |
| 36 | zipFilename := Config{OutputPath: "test.zip"} |
| 37 | zipFilename.detectFromFilename() |
| 38 | if zipFilename.Archive != "zip" { |
| 39 | t.Error("Expected to find zip archive setting") |
| 40 | } |
| 41 | if zipFilename.Algorithm != "" { |
| 42 | t.Error("Expected to find empty algorithm setting") |
| 43 | } |
| 44 | |
| 45 | // Test .compress |
| 46 | lz4Filename := Config{OutputPath: "test.lz4"} |
| 47 | lz4Filename.detectFromFilename() |
| 48 | if lz4Filename.Archive != "" { |
| 49 | t.Error("Expected to find empty archive setting") |
| 50 | } |
| 51 | if lz4Filename.Algorithm != "lz4" { |
| 52 | t.Error("Expected to find lz4 algorithm setting") |
| 53 | } |
| 54 | |
| 55 | // Test .archive.compress with some.extra.dots... |
| 56 | lotsOfDots := Config{OutputPath: "test.blah.bloo.blee.tar.lz4"} |
| 57 | lotsOfDots.detectFromFilename() |
| 58 | if lotsOfDots.Archive != "tar" { |
| 59 | t.Error("Expected to find tar archive setting") |
| 60 | } |
| 61 | if lotsOfDots.Algorithm != "lz4" { |
| 62 | t.Error("Expected to find lz4 algorithm setting") |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | const expectedFileContents = "Hello world!" |
| 67 |
nothing calls this directly
no test coverage detected
searching dependent graphs…