gout

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

page_tests.c (1200B)


      1 #include "writer/gemini/page.h"
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <string.h>
      6 
      7 #include "fs_inmemory.h"
      8 #include "git/repo.h"
      9 #include "test_utils.h"
     10 #include "utest.h"
     11 
     12 struct gemini_page {
     13   int dummy;
     14 };
     15 
     16 UTEST_F_SETUP(gemini_page) {
     17   inmemory_fs_clear();
     18 }
     19 
     20 UTEST_F_TEARDOWN(gemini_page) {}
     21 
     22 UTEST_F(gemini_page, basic) {
     23   RepoSpecialFile sf = {.label = "LICENSE", .path = "LICENSE"};
     24   GitRepo repo = {
     25       .short_name = "test-repo",
     26       .description = "Repo description",
     27       .clone_url = "git://example.com/repo.git",
     28       .special_files = &sf,
     29       .special_files_len = 1,
     30   };
     31 
     32   FILE* out = g_fs_inmemory->fopen("test.gmi", "w");
     33   GeminiPage* page =
     34       gemini_page_create(out, &repo, g_fs_inmemory, "Page Title", "");
     35   ASSERT_NE(NULL, page);
     36 
     37   gemini_page_begin(page);
     38   gemini_page_end(page);
     39   g_fs_inmemory->fclose(out);
     40   gemini_page_free(page);
     41 
     42   const char* buf = inmemory_fs_get_buffer("test.gmi");
     43   ASSERT_NE(NULL, buf);
     44 
     45   EXPECT_STR_SEQUENCE(buf, "# Page Title - test-repo", "> Repo description",
     46                       "git clone", "=> log.gmi Log", "=> files.gmi Files",
     47                       "=> refs.gmi Refs", "=> file/LICENSE.gmi LICENSE");
     48 }