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