2024-01-08 14:53:32 +00:00
|
|
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
// Copied and modified from https://github.com/ethantkoenig/rupture (MIT License)
|
|
|
|
|
|
|
|
package bleve
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-07-30 19:41:10 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-01-08 14:53:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMetadata(t *testing.T) {
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
|
|
|
meta, err := readIndexMetadata(dir)
|
2024-07-30 19:41:10 +00:00
|
|
|
require.NoError(t, err)
|
2024-01-08 14:53:32 +00:00
|
|
|
assert.Equal(t, &IndexMetadata{}, meta)
|
|
|
|
|
|
|
|
meta.Version = 24
|
2024-07-30 19:41:10 +00:00
|
|
|
require.NoError(t, writeIndexMetadata(dir, meta))
|
2024-01-08 14:53:32 +00:00
|
|
|
|
|
|
|
meta, err = readIndexMetadata(dir)
|
2024-07-30 19:41:10 +00:00
|
|
|
require.NoError(t, err)
|
2024-01-08 14:53:32 +00:00
|
|
|
assert.EqualValues(t, 24, meta.Version)
|
|
|
|
}
|