package nsc

import (
	"testing"
	"time"
)

func TestMacOSNSCAttemptConfigForReusesLastFallback(t *testing.T) {
	attempts := []macosNSCAttemptConfig{
		{waitTimeout: time.Minute, createTimeout: 2 * time.Minute},
		{waitTimeout: 30 * time.Second, createTimeout: time.Minute},
	}

	got := macosNSCAttemptConfigFor(3, attempts)
	want := attempts[len(attempts)-1]
	if got != want {
		t.Fatalf("macosNSCAttemptConfigFor(3) = %+v, want %+v", got, want)
	}
}

func TestMacOSNSCAttemptConfigForEmpty(t *testing.T) {
	got := macosNSCAttemptConfigFor(0, nil)
	if got != (macosNSCAttemptConfig{}) {
		t.Fatalf("macosNSCAttemptConfigFor(0, nil) = %+v, want zero value", got)
	}
}
