gitea源码

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package private
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestGitPushOptions(t *testing.T) {
  9. o := GitPushOptions{}
  10. v := o.Bool("no-such")
  11. assert.False(t, v.Has())
  12. assert.False(t, v.Value())
  13. o.AddFromKeyValue("opt1=a=b")
  14. o.AddFromKeyValue("opt2=false")
  15. o.AddFromKeyValue("opt3=true")
  16. o.AddFromKeyValue("opt4")
  17. assert.Equal(t, "a=b", o["opt1"])
  18. assert.False(t, o.Bool("opt1").Value())
  19. assert.True(t, o.Bool("opt2").Has())
  20. assert.False(t, o.Bool("opt2").Value())
  21. assert.True(t, o.Bool("opt3").Value())
  22. assert.True(t, o.Bool("opt4").Value())
  23. }