mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
141 lines
2.3 KiB
Go
141 lines
2.3 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package markdown
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.yaml.in/yaml/v4"
|
|
)
|
|
|
|
func TestRenderConfig_UnmarshalYAML(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
expected *RenderConfig
|
|
args string
|
|
}{
|
|
{
|
|
"empty", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "",
|
|
}, "",
|
|
},
|
|
{
|
|
"lang", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "test",
|
|
}, "lang: test",
|
|
},
|
|
{
|
|
"metatable", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "",
|
|
}, "gitea: table",
|
|
},
|
|
{
|
|
"metanone", &RenderConfig{
|
|
Meta: "none",
|
|
Lang: "",
|
|
}, "gitea: none",
|
|
},
|
|
{
|
|
"metadetails", &RenderConfig{
|
|
Meta: "details",
|
|
Lang: "",
|
|
}, "gitea: details",
|
|
},
|
|
{
|
|
"metawrong", &RenderConfig{
|
|
Meta: "details",
|
|
Lang: "",
|
|
}, "gitea: wrong",
|
|
},
|
|
{
|
|
"toc", &RenderConfig{
|
|
TOC: "true",
|
|
Meta: "table",
|
|
Lang: "",
|
|
}, "include_toc: true",
|
|
},
|
|
{
|
|
"tocfalse", &RenderConfig{
|
|
TOC: "false",
|
|
Meta: "table",
|
|
Lang: "",
|
|
}, "include_toc: false",
|
|
},
|
|
{
|
|
"toclang", &RenderConfig{
|
|
Meta: "table",
|
|
TOC: "true",
|
|
Lang: "testlang",
|
|
}, `
|
|
include_toc: true
|
|
lang: testlang
|
|
`,
|
|
},
|
|
{
|
|
"complexlang", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "testlang",
|
|
}, `
|
|
gitea:
|
|
lang: testlang
|
|
`,
|
|
},
|
|
{
|
|
"complexlang2", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "testlang",
|
|
}, `
|
|
lang: notright
|
|
gitea:
|
|
lang: testlang
|
|
`,
|
|
},
|
|
{
|
|
"complexlang", &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "testlang",
|
|
}, `
|
|
gitea:
|
|
lang: testlang
|
|
`,
|
|
},
|
|
{
|
|
"complex2", &RenderConfig{
|
|
Lang: "two",
|
|
Meta: "table",
|
|
TOC: "true",
|
|
}, `
|
|
lang: one
|
|
include_toc: true
|
|
gitea:
|
|
details_icon: smiley
|
|
meta: table
|
|
include_toc: true
|
|
lang: two
|
|
`,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := &RenderConfig{
|
|
Meta: "table",
|
|
Lang: "",
|
|
}
|
|
err := yaml.Unmarshal([]byte(strings.ReplaceAll(tt.args, "\t", " ")), got)
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, tt.expected.Meta, got.Meta)
|
|
assert.Equal(t, tt.expected.Lang, got.Lang)
|
|
assert.Equal(t, tt.expected.TOC, got.TOC)
|
|
})
|
|
}
|
|
}
|