2024-01-08 09:53:32 -05: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 15:41:27 -04:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-01-08 09:53:32 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMetadata(t *testing.T) {
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
|
|
|
meta, err := readIndexMetadata(dir)
|
2024-07-30 15:41:27 -04:00
|
|
|
require.NoError(t, err)
|
2024-01-08 09:53:32 -05:00
|
|
|
assert.Equal(t, &IndexMetadata{}, meta)
|
|
|
|
|
|
|
|
meta.Version = 24
|
2024-07-30 15:41:27 -04:00
|
|
|
require.NoError(t, writeIndexMetadata(dir, meta))
|
2024-01-08 09:53:32 -05:00
|
|
|
|
|
|
|
meta, err = readIndexMetadata(dir)
|
2024-07-30 15:41:27 -04:00
|
|
|
require.NoError(t, err)
|
2024-01-08 09:53:32 -05:00
|
|
|
assert.EqualValues(t, 24, meta.Version)
|
|
|
|
}
|