gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

repo_writer_tests.c (1584B)


      1 #include "writer/gemini/repo_writer.h"
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <string.h>
      6 
      7 #include "fs_inmemory.h"
      8 #include "git/commit.h"
      9 #include "git/repo.h"
     10 #include "utest.h"
     11 
     12 struct gemini_repo_writer {
     13   int dummy;
     14 };
     15 
     16 UTEST_F_SETUP(gemini_repo_writer) {
     17   inmemory_fs_clear();
     18 }
     19 
     20 UTEST_F_TEARDOWN(gemini_repo_writer) {}
     21 
     22 UTEST_F(gemini_repo_writer, orchestration) {
     23   GitRepo repo = {
     24       .name = "test-repo.git",
     25       .short_name = "test-repo",
     26       .description = "A test repository",
     27       .owner = "Test Owner",
     28       .clone_url = "git://example.com/test-repo.git",
     29   };
     30   GeminiRepoWriter* writer = gemini_repowriter_create(&repo, g_fs_inmemory);
     31   ASSERT_NE(NULL, writer);
     32 
     33   GitCommit commit = {
     34       .oid = "sha123",
     35       .parentoid = "",
     36       .summary = "Test commit",
     37       .message = "Detailed message.",
     38       .author_name = "User",
     39       .author_email = "user@example.com",
     40   };
     41 
     42   gemini_repowriter_begin(writer);
     43   gemini_repowriter_add_commit(writer, &commit);
     44   gemini_repowriter_end(writer);
     45   gemini_repowriter_free(writer);
     46 
     47   /* Verify orchestration by checking multiple output files. */
     48 
     49   /* 1. Log file exists and contains the commit message. */
     50   const char* log_buf = inmemory_fs_get_buffer("log.gmi");
     51   ASSERT_NE(NULL, log_buf);
     52   EXPECT_NE(NULL, strstr(log_buf, "Test commit"));
     53 
     54   /* 2. Individual commit page exists. */
     55   const char* commit_buf = inmemory_fs_get_buffer("commit/sha123.gmi");
     56   ASSERT_NE(NULL, commit_buf);
     57   EXPECT_NE(NULL, strstr(commit_buf, "Test commit"));
     58   EXPECT_NE(NULL, strstr(commit_buf, "sha123"));
     59 }