forked from gohugoio/hugo
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: Rework page store, add a dynacache to enable bigger data/content…
…, and some general spring cleaning There are some breaking changes in this commit, see gohugoio#11455. Closes gohugoio#11455 Closes gohugoio#11549 Fixes gohugoio#10104 Fixes gohugoio#10380 Fixes gohugoio#10694 Fixes gohugoio#11439 Fixes gohugoio#11453 Fixes gohugoio#11457 Fixes gohugoio#11466 Fixes gohugoio#11540 Fixes gohugoio#11551 Fixes gohugoio#11556 Fixes gohugoio#11654 Fixes gohugoio#11661 Fixes gohugoio#11663 Fixes gohugoio#11840 Fixes gohugoio#11664 Fixes gohugoio#11669 Fixes gohugoio#11671 Fixes gohugoio#11807 Fixes gohugoio#11808 Fixes gohugoio#11809 Fixes gohugoio#11815 Fixes gohugoio#7425 Fixes gohugoio#7436 Fixes gohugoio#7437 Fixes gohugoio#7544 Fixes gohugoio#7882 Fixes gohugoio#8307 Fixes gohugoio#8498 Fixes gohugoio#8927 Fixes gohugoio#9192 Fixes gohugoio#9324 Fixes gohugoio#9343
- Loading branch information
Showing
345 changed files
with
16,641 additions
and
17,164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2023 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package dynacache | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
qt "github.com/frankban/quicktest" | ||
"github.com/gohugoio/hugo/common/loggers" | ||
) | ||
|
||
func TestCache(t *testing.T) { | ||
t.Parallel() | ||
c := qt.New(t) | ||
|
||
cache := New(Options{ | ||
Log: loggers.NewDefault(), | ||
}) | ||
opts := OptionsPartition{Weight: 30} | ||
|
||
c.Assert(cache, qt.Not(qt.IsNil)) | ||
|
||
p1 := GetOrCreatePartition[string, testItem](cache, "/aaaa/bbbb", opts) | ||
c.Assert(p1, qt.Not(qt.IsNil)) | ||
|
||
p2 := GetOrCreatePartition[string, testItem](cache, "/aaaa/bbbb", opts) | ||
c.Assert(p2, qt.Equals, p1) | ||
|
||
p3 := GetOrCreatePartition[string, testItem](cache, "/aaaa/cccc", opts) | ||
c.Assert(p3, qt.Not(qt.IsNil)) | ||
c.Assert(p3, qt.Not(qt.Equals), p1) | ||
} | ||
|
||
type testItem struct{} | ||
|
||
func TestCalculateMaxSizePerPartition(t *testing.T) { | ||
t.Parallel() | ||
c := qt.New(t) | ||
|
||
c.Assert(calculateMaxSizePerPartition(1000, 500, 5), qt.Equals, 200) | ||
c.Assert(calculateMaxSizePerPartition(1000, 250, 5), qt.Equals, 400) | ||
} | ||
|
||
func TestCleanKey(t *testing.T) { | ||
c := qt.New(t) | ||
|
||
c.Assert(CleanKey("a/b/c"), qt.Equals, "/a/b/c") | ||
c.Assert(CleanKey("/a/b/c"), qt.Equals, "/a/b/c") | ||
c.Assert(CleanKey("a/b/c/"), qt.Equals, "/a/b/c") | ||
c.Assert(CleanKey(filepath.FromSlash("/a/b/c/")), qt.Equals, "/a/b/c") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.