Fosi Fossil Service
Small teams. Open source. Built on Fossil.

CaaS / Lamina

Unified Management for Fossil Repositories

Public | Owner: CaaS | Default branch: trunk | Last update: 2026-10-25 00:41

Artifact a4f6f51dec745a709182296cb3424023f0ada0c574da9453bafb218821332cfb:


(defmodule lamina_validate_tests
  (export all)
  (include-lib "eunit/include/eunit.hrl"))

(defun valid-slug_test ()
  (lists:foreach
   (lambda (slug)
     (case (lamina_validate:check-slug slug)
       ('ok 'ok)
       (other (erlang:error (list "valid slug rejected" slug other)))))
   (list "demo-repo-2" "Demo" "Acme" "NigFossil")))

(defun invalid-slug_test ()
  (let ((cases (list "-demo" "demo_2" "" "Demo Repo")))
    (lists:foreach
     (lambda (slug)
       (case (lamina_validate:check-slug slug)
         (`#(error ,_) 'ok)
         (other (erlang:error (list "invalid slug accepted" slug other)))))
     cases)
    'ok))

(defun reserved-slug_test ()
  (lists:foreach
   (lambda (slug)
     (case (lamina_validate:check-slug slug)
       (`#(error ,_) 'ok)
       (other (erlang:error (list "reserved slug accepted" slug other)))))
   (list "admin" "Admin" "LOGIN")))

(defun availability-conflict_test ()
  (let ((dir (tmpdir)))
    (case (lamina_db:open (filename:join dir "test.db"))
      (`#(ok ,_)
       (lamina_db:q "INSERT INTO repositories(name,organization_id,source,setup_username,setup_password_enc,fossil_path,created_at,updated_at) VALUES(?,NULL,'local',?,x'00',?,?,?);"
                       (list "demo" "admin" (filename:join dir "demo.fossil") "now" "now"))
       (let ((result (lamina_validate:check-availability 'none "demo")))
         (lamina_db:close)
         (file:del_dir_r dir)
         (case result
           (`#(error ,_) 'ok)
           (other (erlang:error (list "duplicate slug accepted" other))))))
      (other (file:del_dir_r dir) (erlang:error "database setup failed")))))

(defun organization-combination-conflict_test ()
  (let ((dir (tmpdir)))
    (case (lamina_db:open (filename:join dir "test.db"))
      (`#(ok ,_)
       (lamina_db:exec "INSERT INTO organizations(name,description,created_at) VALUES('acme','','now');")
       (let ((org-id (lamina_db:last-rowid)))
         (lamina_db:q "INSERT INTO repositories(name,organization_id,source,setup_username,setup_password_enc,fossil_path,created_at,updated_at) VALUES(?,?,'local',?,x'00',?,?,?);"
                         (list "demo" org-id "admin" (filename:join dir "acme-demo.fossil") "now" "now"))
         (let ((result (lamina_validate:check-availability "acme" "demo")))
           (lamina_db:close)
           (file:del_dir_r dir)
           (case result
             (`#(error ,_) 'ok)
             (other (erlang:error (list "organization slug conflict accepted" other)))))))
      (other (file:del_dir_r dir) (erlang:error "database setup failed")))))

(defun tmpdir ()
  (let* ((cwd (element 2 (file:get_cwd)))
         (base (filename:join cwd "_build/tmp"))
         (name (lists:flatten (io_lib:format "validate-~p" (list (os:system_time 'microsecond))))))
    (filelib:ensure_dir (filename:join base "x"))
    (let ((dir (filename:join base name)))
      (file:make_dir dir)
      dir)))

Clone

You can clone this repository with the following command:

fossil clone https://fosi.dev/CaaS/Lamina

Contribute

The best way to contribute is through e-mail. See the project documentation for more details.