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