github.com/sercand/please@v13.4.0+incompatible/src/help/help_test.go (about)

     1  package help
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestPublicInterface(t *testing.T) {
    10  	// Quick test on the main Help function; it doesn't expose much information so other
    11  	// tests use non-exported functions to get a bit more detail.
    12  	assert.True(t, Help("go_binary"))
    13  	assert.False(t, Help("go_binaryz"))
    14  	assert.False(t, Help("wibble"))
    15  }
    16  
    17  func TestHelpDescription(t *testing.T) {
    18  	// The returned message should describe what kind of a thing it is
    19  	assert.Contains(t, help("go_binary"), "built-in build rule")
    20  	// And what its name was
    21  	assert.Contains(t, help("go_binary"), "go_binary")
    22  }
    23  
    24  func TestSuggestion(t *testing.T) {
    25  	assert.Equal(t, "\nMaybe you meant cc_embed_binary or c_embed_binary ?", suggest("cc_emdbed_binary"))
    26  	assert.Equal(t, "\nMaybe you meant godep or go ?", suggest("godop"))
    27  	assert.Equal(t, "", suggest("blahdiblahdiblah"))
    28  }
    29  
    30  func TestConfig(t *testing.T) {
    31  	assert.Contains(t, help("NumThreads"), "config setting")
    32  	assert.Contains(t, help("numthreads"), "config setting")
    33  }
    34  
    35  func TestMisc(t *testing.T) {
    36  	assert.Contains(t, help("plzconfig"), "plzconfig")
    37  }
    38  
    39  func TestGeneralMessage(t *testing.T) {
    40  	// Should provide some useful message for just "plz halp"
    41  	assert.NotEqual(t, "", help(""))
    42  }
    43  
    44  func TestTopics(t *testing.T) {
    45  	assert.NotEqual(t, "", help("topics"))
    46  }