Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

915 B
Raw Blame
package identifier

import (
	"testing"
)

func TestUIDMatcher(t *testing.T) {
	tests := []struct {
		input    string
		expected bool
	}{
		{"", false},
		{"-abc123", false},
		{"012345678901234567890123456789", true},
		{"1abc-123", true},
		{"A123B456C789", true},
		{"a", true},
		{"ab", true},
		{"a*b&c", false},
		{"a--b", true},
		{"a-1b-2c", true},
		{"a1234567890123456789012345678901", true},
		{"abc123", true},
		{"abc123-", false},
		{"123e4567-e89b-12d3-a456-426614174000", true},   // UUID v4 from IDP
		{"a12345678901234567890123456789012345", true},   // 36 characters.
		{"a123456789012345678901234567890123456", false}, // 37 characters.
	}

	for _, test := range tests {
		t.Run(test.input, func(*testing.T) {
			result := UIDMatcher.MatchString(test.input)
			if result != test.expected {
				t.Errorf("For input '%s', expected %v but got %v", test.input, test.expected, result)
			}
		})
	}
}