2012-10-13 05:32:04 +08:00
|
|
|
package tail
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Test Config.MustExist
|
|
|
|
func TestMissingFile(t *testing.T) {
|
|
|
|
_, err := TailFile("/no/such/file", Config{Follow: true, MustExist: true})
|
|
|
|
if err == nil {
|
|
|
|
t.Error("MustExist:true is violated")
|
|
|
|
}
|
2012-10-13 07:28:22 +08:00
|
|
|
_, err = TailFile("/no/such/file", Config{Follow: true, MustExist: false})
|
2012-10-13 05:32:04 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Error("MustExist:false is violated")
|
|
|
|
}
|
2012-10-13 07:28:22 +08:00
|
|
|
_, err = TailFile("README.md", Config{Follow: true, MustExist: true})
|
|
|
|
if err != nil {
|
|
|
|
t.Error("MustExist:true on an existing file is violated")
|
|
|
|
}
|
2012-10-13 05:32:04 +08:00
|
|
|
}
|