Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

867 B
Raw Blame
//go:build boxlite_runner && boxlite_dev && (boxlite_integration || boxlite_ssh_usage_test)

package boxlite

import (
	"context"
	"testing"
)

func TestSSHUsageConfiguredLocalBoxReturnsOwnedEmptyBatchWithoutBoot(t *testing.T) {
	rt, err := NewRuntime(WithHomeDir(t.TempDir()))
	if err != nil {
		t.Fatal(err)
	}
	defer rt.Close()
	box, err := rt.Create(context.Background(), "alpine:latest", WithName("usage-idle"), WithAutoRemove(false))
	if err != nil {
		t.Fatal(err)
	}
	defer box.Close()
	batch, err := box.SSH().RunnerTakeUsage(context.Background())
	if err != nil || batch == nil || len(batch.Events) != 0 || batch.DroppedTotal != 0 {
		t.Fatalf("batch=%v err=%v", batch, err)
	}
	info, err := box.Info(context.Background())
	if err != nil {
		t.Fatal(err)
	}
	if info.Running || info.PID != 0 {
		t.Fatalf("usage observation booted the Box: %#v", info)
	}
}