// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com). // All rights reserved. // main.go package main import ( "path" "slices" "testing" ) func TestIsPattern(t *testing.T) { target := "non-pattern" if isPattern(target) { t.Errorf("%q recognized as a pattern", target) } target = "pattern/*.expr" if !isPattern(target) { t.Errorf("%q not recognized as a pattern", target) } } func TestMatchFilePattern(t *testing.T) { target := "./go.*sum" dirName := path.Dir(target) pattern := path.Base(target) if matchedFiles, err := matchFilePattern(dirName, pattern, true); err == nil { if slices.Compare(matchedFiles, []string{"go.sum", "go.work.sum"}) != 0 { t.Errorf("Matched file list is not correct: %v", matchedFiles) } } else { t.Errorf("Got error: %v", err) } }