删除测试报告
This commit is contained in:
parent
0942d6db20
commit
b70a38e4b1
|
@ -1,195 +0,0 @@
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>index: Go Coverage Report</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: black;
|
|
||||||
color: rgb(80, 80, 80);
|
|
||||||
}
|
|
||||||
body, pre, #legend span {
|
|
||||||
font-family: Menlo, monospace;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
#topbar {
|
|
||||||
background: black;
|
|
||||||
position: fixed;
|
|
||||||
top: 0; left: 0; right: 0;
|
|
||||||
height: 42px;
|
|
||||||
border-bottom: 1px solid rgb(80, 80, 80);
|
|
||||||
}
|
|
||||||
#content {
|
|
||||||
margin-top: 50px;
|
|
||||||
}
|
|
||||||
#nav, #legend {
|
|
||||||
float: left;
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
#legend {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
#nav {
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
#legend span {
|
|
||||||
margin: 0 5px;
|
|
||||||
}
|
|
||||||
.cov0 { color: rgb(192, 0, 0) }
|
|
||||||
.cov1 { color: rgb(128, 128, 128) }
|
|
||||||
.cov2 { color: rgb(116, 140, 131) }
|
|
||||||
.cov3 { color: rgb(104, 152, 134) }
|
|
||||||
.cov4 { color: rgb(92, 164, 137) }
|
|
||||||
.cov5 { color: rgb(80, 176, 140) }
|
|
||||||
.cov6 { color: rgb(68, 188, 143) }
|
|
||||||
.cov7 { color: rgb(56, 200, 146) }
|
|
||||||
.cov8 { color: rgb(44, 212, 149) }
|
|
||||||
.cov9 { color: rgb(32, 224, 152) }
|
|
||||||
.cov10 { color: rgb(20, 236, 155) }
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="topbar">
|
|
||||||
<div id="nav">
|
|
||||||
<select id="files">
|
|
||||||
|
|
||||||
<option value="file0">git.pyer.club/kingecg/godocdb/index/index.go (82.1%)</option>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div id="legend">
|
|
||||||
<span>not tracked</span>
|
|
||||||
|
|
||||||
<span class="cov0">not covered</span>
|
|
||||||
<span class="cov8">covered</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<pre class="file" id="file0" style="display: none">package index
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/iancoleman/orderedmap"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"git.pyer.club/kingecg/godocdb/storage"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IndexType 表示索引类型
|
|
||||||
type IndexType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
SingleField IndexType = "single"
|
|
||||||
Composite IndexType = "composite"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IndexMetadata 索引元数据
|
|
||||||
type IndexMetadata struct {
|
|
||||||
Name string
|
|
||||||
Type IndexType
|
|
||||||
KeyFields []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// IndexStore 管理索引的存储和查询
|
|
||||||
type IndexStore struct {
|
|
||||||
storage *storage.LevelDBStorage
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewIndexStore 创建新的索引存储实例
|
|
||||||
func NewIndexStore(path string) (*IndexStore, error) <span class="cov8" title="1">{
|
|
||||||
storage, err := storage.NewLevelDBStorage(path)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
<span class="cov8" title="1">return &IndexStore{storage: storage}, nil</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateIndex 创建索引
|
|
||||||
func (is *IndexStore) CreateIndex(indexName string, indexType IndexType, keyFields []string) error <span class="cov8" title="1">{
|
|
||||||
// 存储索引元数据
|
|
||||||
metadata := IndexMetadata{
|
|
||||||
Name: indexName,
|
|
||||||
Type: indexType,
|
|
||||||
KeyFields: keyFields,
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := bson.Marshal(metadata)
|
|
||||||
if err != nil </span><span class="cov0" title="0">{
|
|
||||||
return fmt.Errorf("failed to marshal index metadata: %v", err)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
<span class="cov8" title="1">key := []byte(fmt.Sprintf("indexes:metadata:%s", indexName))
|
|
||||||
if err := is.storage.Put(key, data); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
// 初始化索引存储结构
|
|
||||||
<span class="cov8" title="1">indexKey := fmt.Sprintf("indexes:data:%s", indexName)
|
|
||||||
index := orderedmap.New()
|
|
||||||
indexData, _ := bson.Marshal(index)
|
|
||||||
return is.storage.Put([]byte(indexKey), indexData)</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
// DropIndex 删除索引
|
|
||||||
func (is *IndexStore) DropIndex(indexName string) error <span class="cov8" title="1">{
|
|
||||||
// 删除元数据
|
|
||||||
metadataKey := []byte(fmt.Sprintf("indexes:metadata:%s", indexName))
|
|
||||||
if err := is.storage.Delete(metadataKey); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return err
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
// 删除索引数据
|
|
||||||
<span class="cov8" title="1">indexKey := []byte(fmt.Sprintf("indexes:data:%s", indexName))
|
|
||||||
return is.storage.Delete(indexKey)</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetIndexMetadata 获取索引元数据
|
|
||||||
func (is *IndexStore) GetIndexMetadata(indexName string) (*IndexMetadata, error) <span class="cov8" title="1">{
|
|
||||||
key := []byte(fmt.Sprintf("indexes:metadata:%s", indexName))
|
|
||||||
rawData, err := is.storage.Get(key)
|
|
||||||
if err != nil </span><span class="cov8" title="1">{
|
|
||||||
return nil, fmt.Errorf("index not found: %v", err)
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
<span class="cov8" title="1">var metadata IndexMetadata
|
|
||||||
if err := bson.Unmarshal(rawData, &metadata); err != nil </span><span class="cov0" title="0">{
|
|
||||||
return nil, err
|
|
||||||
}</span>
|
|
||||||
|
|
||||||
<span class="cov8" title="1">return &metadata, nil</span>
|
|
||||||
}</pre>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<script>
|
|
||||||
(function() {
|
|
||||||
var files = document.getElementById('files');
|
|
||||||
var visible;
|
|
||||||
files.addEventListener('change', onChange, false);
|
|
||||||
function select(part) {
|
|
||||||
if (visible)
|
|
||||||
visible.style.display = 'none';
|
|
||||||
visible = document.getElementById(part);
|
|
||||||
if (!visible)
|
|
||||||
return;
|
|
||||||
files.value = part;
|
|
||||||
visible.style.display = 'block';
|
|
||||||
location.hash = part;
|
|
||||||
}
|
|
||||||
function onChange() {
|
|
||||||
select(files.value);
|
|
||||||
window.scrollTo(0, 0);
|
|
||||||
}
|
|
||||||
if (location.hash != "") {
|
|
||||||
select(location.hash.substr(1));
|
|
||||||
}
|
|
||||||
if (!visible) {
|
|
||||||
select("file0");
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue