package wails_test

import (
	"testing"

	"github.com/leonmika/wails-release/internal/wails"
)

func TestReadProject_ReturnsAppName(t *testing.T) {
	p, err := wails.ReadProject("testdata/sample")
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	if p.Name != "SampleApp" {
		t.Fatalf("name: got %q want SampleApp", p.Name)
	}
}

func TestReadProject_MissingWailsJSONErrors(t *testing.T) {
	_, err := wails.ReadProject("testdata/missing")
	if err == nil {
		t.Fatal("expected error for missing wails.json")
	}
}

func TestProjectWailsVersion_FromGoMod(t *testing.T) {
	v, err := wails.ProjectWailsVersion("testdata/sample")
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	if v != "v2.11.0" {
		t.Fatalf("got %q, want v2.11.0", v)
	}
}

func TestProjectWailsVersion_NoWailsDependencyErrors(t *testing.T) {
	_, err := wails.ProjectWailsVersion("testdata/no-wails")
	if err == nil {
		t.Fatal("expected error for project with no wails dep")
	}
}
