mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-04 19:32:30 +00:00
improve test and comment
This commit is contained in:
parent
1d333296eb
commit
a0cfb36717
@ -102,13 +102,17 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
|
|||||||
}, attr)
|
}, attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedAttrs = Attributes{
|
func expectedAttrs() *Attributes {
|
||||||
LinguistGenerated: "unspecified",
|
return &Attributes{
|
||||||
LinguistDetectable: "unspecified",
|
m: map[string]Attribute{
|
||||||
LinguistDocumentation: "unspecified",
|
LinguistGenerated: "unspecified",
|
||||||
LinguistVendored: "unspecified",
|
LinguistDetectable: "unspecified",
|
||||||
LinguistLanguage: "Python",
|
LinguistDocumentation: "unspecified",
|
||||||
GitlabLanguage: "unspecified",
|
LinguistVendored: "unspecified",
|
||||||
|
LinguistLanguage: "Python",
|
||||||
|
GitlabLanguage: "unspecified",
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_BatchChecker(t *testing.T) {
|
func Test_BatchChecker(t *testing.T) {
|
||||||
@ -127,7 +131,7 @@ func Test_BatchChecker(t *testing.T) {
|
|||||||
defer checker.Close()
|
defer checker.Close()
|
||||||
attributes, err := checker.CheckPath("i-am-a-python.p")
|
attributes, err := checker.CheckPath("i-am-a-python.p")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expectedAttrs, attributes)
|
assert.Equal(t, expectedAttrs(), attributes)
|
||||||
})
|
})
|
||||||
|
|
||||||
// run git check-attr on work tree
|
// run git check-attr on work tree
|
||||||
@ -148,7 +152,7 @@ func Test_BatchChecker(t *testing.T) {
|
|||||||
defer checker.Close()
|
defer checker.Close()
|
||||||
attributes, err := checker.CheckPath("i-am-a-python.p")
|
attributes, err := checker.CheckPath("i-am-a-python.p")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expectedAttrs, attributes)
|
assert.Equal(t, expectedAttrs(), attributes)
|
||||||
})
|
})
|
||||||
|
|
||||||
if !git.DefaultFeatures().SupportCheckAttrOnBare {
|
if !git.DefaultFeatures().SupportCheckAttrOnBare {
|
||||||
@ -163,6 +167,6 @@ func Test_BatchChecker(t *testing.T) {
|
|||||||
|
|
||||||
attributes, err := checker.CheckPath("i-am-a-python.p")
|
attributes, err := checker.CheckPath("i-am-a-python.p")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expectedAttrs, attributes)
|
assert.Equal(t, expectedAttrs(), attributes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ func checkAttrCommand(gitRepo *git.Repository, treeish string, filenames, attrib
|
|||||||
cmd.AddArguments("--all")
|
cmd.AddArguments("--all")
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is treeish, read from source or index
|
// there is treeish, read from bare repo or temp index created by "read-tree"
|
||||||
if treeish != "" {
|
if treeish != "" {
|
||||||
if git.DefaultFeatures().SupportCheckAttrOnBare {
|
if git.DefaultFeatures().SupportCheckAttrOnBare {
|
||||||
cmd.AddArguments("--source")
|
cmd.AddArguments("--source")
|
||||||
@ -39,7 +39,7 @@ func checkAttrCommand(gitRepo *git.Repository, treeish string, filenames, attrib
|
|||||||
)
|
)
|
||||||
cancel = deleteTemporaryFile
|
cancel = deleteTemporaryFile
|
||||||
}
|
}
|
||||||
} // no treeish, read from working directory
|
} // else: no treeish, assume it is a not a bare repo, read from working directory
|
||||||
|
|
||||||
cmd.AddDynamicArguments(attributes...)
|
cmd.AddDynamicArguments(attributes...)
|
||||||
if len(filenames) > 0 {
|
if len(filenames) > 0 {
|
||||||
|
@ -32,7 +32,7 @@ func Test_Checker(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, attrs, 1)
|
assert.Len(t, attrs, 1)
|
||||||
assert.Equal(t, expectedAttrs, attrs["i-am-a-python.p"])
|
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
|
||||||
})
|
})
|
||||||
|
|
||||||
// run git check-attr on work tree
|
// run git check-attr on work tree
|
||||||
@ -54,7 +54,7 @@ func Test_Checker(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, attrs, 1)
|
assert.Len(t, attrs, 1)
|
||||||
assert.Equal(t, expectedAttrs, attrs["i-am-a-python.p"])
|
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
|
||||||
})
|
})
|
||||||
|
|
||||||
if !git.DefaultFeatures().SupportCheckAttrOnBare {
|
if !git.DefaultFeatures().SupportCheckAttrOnBare {
|
||||||
@ -69,6 +69,6 @@ func Test_Checker(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, attrs, 1)
|
assert.Len(t, attrs, 1)
|
||||||
assert.Equal(t, expectedAttrs, attrs["i-am-a-python.p"])
|
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user