package runnercfg

import (
	"context"
	"os"
	"path/filepath"
	"testing"
)

func TestPingDockerUnreachable(t *testing.T) {
	dir := t.TempDir()
	bin := filepath.Join(dir, "docker")
	if err := os.WriteFile(bin, []byte("#!/bin/sh\necho boom >&2\nexit 1\n"), 0o755); err != nil {
		t.Fatal(err)
	}
	st := PingDocker(context.Background(), bin)
	if st.Reachable || st.Error == "" {
		t.Fatalf("%+v", st)
	}
}

func TestPingDockerMissingBinary(t *testing.T) {
	st := PingDocker(context.Background(), filepath.Join(t.TempDir(), "nope"))
	if st.Reachable || st.Error == "" {
		t.Fatalf("%+v", st)
	}
}
