lib/ignore: Centralize handling of temporary filenames (fixes #3899)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3901
LGTM: calmh, AudriusButkevicius
This commit is contained in:
Simon Frei
2017-01-17 07:33:48 +00:00
committed by Audrius Butkevicius
parent 929a4d0c0c
commit dbb3a34887
7 changed files with 60 additions and 66 deletions

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2015 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package ignore
import (
"strings"
"testing"
)
func TestLongTempFilename(t *testing.T) {
filename := ""
for i := 0; i < 300; i++ {
filename += "l"
}
tFile := TempName(filename)
if len(tFile) < 10 || len(tFile) > 200 {
t.Fatal("Invalid long filename")
}
if !strings.HasSuffix(TempName("short"), "short.tmp") {
t.Fatal("Invalid short filename", TempName("short"))
}
}