Rod Hynes 4 лет назад
Родитель
Сommit
1e7146de64
2 измененных файлов с 11 добавлено и 5 удалено
  1. 5 0
      psiphon/common/parameters/parameters_test.go
  2. 6 5
      psiphon/common/utils_test.go

+ 5 - 0
psiphon/common/parameters/parameters_test.go

@@ -44,6 +44,11 @@ func TestGetDefaultParameters(t *testing.T) {
 			if v != g {
 				t.Fatalf("String returned %+v expected %+v", g, v)
 			}
+		case []string:
+			g := p.Get().Strings(name)
+			if !reflect.DeepEqual(v, g) {
+				t.Fatalf("Strings returned %+v expected %+v", g, v)
+			}
 		case int:
 			g := p.Get().Int(name)
 			if v != g {

+ 6 - 5
psiphon/common/utils_test.go

@@ -148,18 +148,19 @@ func TestSafeParseRequestURI(t *testing.T) {
 func TestSleepWithContext(t *testing.T) {
 
 	start := time.Now()
-	SleepWithContext(context.Background(), 2*time.Millisecond)
+	SleepWithContext(context.Background(), 100*time.Millisecond)
 	duration := time.Since(start)
-	if duration/time.Millisecond != 2 {
+	// Allows for 100-109ms actual elapsed time.
+	if duration/time.Millisecond/10 != 10 {
 		t.Errorf("unexpected duration: %v", duration)
 	}
 
 	start = time.Now()
-	ctx, cancelFunc := context.WithTimeout(context.Background(), 1*time.Millisecond)
+	ctx, cancelFunc := context.WithTimeout(context.Background(), 100*time.Millisecond)
 	defer cancelFunc()
-	SleepWithContext(ctx, 2*time.Millisecond)
+	SleepWithContext(ctx, 50*time.Millisecond)
 	duration = time.Since(start)
-	if duration/time.Millisecond != 1 {
+	if duration/time.Millisecond/10 != 5 {
 		t.Errorf("unexpected duration: %v", duration)
 	}
 }