mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-15 10:43:21 +02:00
Fix lint
This commit is contained in:
parent
89af9e2f01
commit
d22069de0b
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package renderplugin
|
package renderplugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -50,7 +53,6 @@ func TestManifestNormalizeErrors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
m := base
|
m := base
|
||||||
tt.mutate(&m)
|
tt.mutate(&m)
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import (
|
|||||||
"code.gitea.io/gitea/tests"
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@ -69,7 +68,7 @@ func TestRenderPluginLifecycle(t *testing.T) {
|
|||||||
assert.Contains(t, flash.SuccessMsg, "disabled")
|
assert.Contains(t, flash.SuccessMsg, "disabled")
|
||||||
row = requireRenderPluginRow(t, session, pluginID)
|
row = requireRenderPluginRow(t, session, pluginID)
|
||||||
assert.False(t, row.Enabled)
|
assert.False(t, row.Enabled)
|
||||||
require.Len(t, fetchRenderPluginMetadata(t), 0)
|
require.Empty(t, fetchRenderPluginMetadata(t))
|
||||||
|
|
||||||
postPluginAction(t, session, fmt.Sprintf("/-/admin/render-plugins/%d/delete", row.ID))
|
postPluginAction(t, session, fmt.Sprintf("/-/admin/render-plugins/%d/delete", row.ID))
|
||||||
flash = expectFlashSuccess(t, session)
|
flash = expectFlashSuccess(t, session)
|
||||||
|
|||||||
@ -3,24 +3,24 @@ import {describe, expect, it, vi} from 'vitest';
|
|||||||
import {decodeHeadChunk} from './file-view.ts';
|
import {decodeHeadChunk} from './file-view.ts';
|
||||||
|
|
||||||
describe('decodeHeadChunk', () => {
|
describe('decodeHeadChunk', () => {
|
||||||
it('returns null when input is empty', () => {
|
it('returns null when input is empty', () => {
|
||||||
expect(decodeHeadChunk(null)).toBeNull();
|
expect(decodeHeadChunk(null)).toBeNull();
|
||||||
expect(decodeHeadChunk('')).toBeNull();
|
expect(decodeHeadChunk('')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('decodes base64 content into a Uint8Array', () => {
|
it('decodes base64 content into a Uint8Array', () => {
|
||||||
const data = 'Gitea Render Plugin';
|
const data = 'Gitea Render Plugin';
|
||||||
const encoded = Buffer.from(data, 'utf-8').toString('base64');
|
const encoded = Buffer.from(data, 'utf-8').toString('base64');
|
||||||
const decoded = decodeHeadChunk(encoded);
|
const decoded = decodeHeadChunk(encoded);
|
||||||
expect(decoded).not.toBeNull();
|
expect(decoded).not.toBeNull();
|
||||||
expect(new TextDecoder().decode(decoded!)).toBe(data);
|
expect(new TextDecoder().decode(decoded!)).toBe(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('logs and returns null for invalid input', () => {
|
it('logs and returns null for invalid input', () => {
|
||||||
const spy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
const spy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
const result = decodeHeadChunk('%invalid-base64%');
|
const result = decodeHeadChunk('%invalid-base64%');
|
||||||
expect(result).toBeNull();
|
expect(result).toBeNull();
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
spy.mockRestore();
|
spy.mockRestore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user