Golang arduino-cc-builder.SetupHumanLoggerIfMissing类(方法)实例源码

下面列出了Golang arduino-cc-builder.SetupHumanLoggerIfMissing 类(方法)源码代码实例,从而了解它的用法。

作者:ricklo    项目:arduino-builde   
func TestLoadSketch(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_SKETCH_LOCATION] = filepath.Join("sketch1", "sketch.ino")

	loggerCommand := builder.SetupHumanLoggerIfMissing{}
	err := loggerCommand.Run(context)
	NoError(t, err)

	loader := builder.SketchLoader{}
	err = loader.Run(context)
	NoError(t, err)

	sketch := context[constants.CTX_SKETCH].(*types.Sketch)
	require.NotNil(t, sketch)

	require.True(t, strings.Index(sketch.MainFile.Name, "sketch.ino") != -1)

	require.Equal(t, 2, len(sketch.OtherSketchFiles))
	require.True(t, strings.Index(sketch.OtherSketchFiles[0].Name, "old.pde") != -1)
	require.True(t, strings.Index(sketch.OtherSketchFiles[1].Name, "other.ino") != -1)

	require.Equal(t, 2, len(sketch.AdditionalFiles))
	require.True(t, strings.Index(sketch.AdditionalFiles[0].Name, "header.h") != -1)
	require.True(t, strings.Index(sketch.AdditionalFiles[1].Name, "helper.h") != -1)
}

作者:stevemarpl    项目:arduino-builde   
func TestFailToLoadSketchFromFolder(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_SKETCH_LOCATION] = "./sketch1"

	loggerCommand := builder.SetupHumanLoggerIfMissing{}
	err := loggerCommand.Run(context)
	NoError(t, err)

	loader := builder.SketchLoader{}
	err = loader.Run(context)
	require.Error(t, err)

	sketch := context[constants.CTX_SKETCH]
	require.Nil(t, sketch)
}

作者:stevemarpl    项目:arduino-builde   
func TestLoadSketchNonExistentPath(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_SKETCH_LOCATION] = "asdasd78128123981723981273asdasd"

	loggerCommand := builder.SetupHumanLoggerIfMissing{}
	err := loggerCommand.Run(context)
	NoError(t, err)

	loader := builder.SketchLoader{}
	err = loader.Run(context)

	require.Error(t, err)

	sketch := context[constants.CTX_SKETCH]
	require.Nil(t, sketch)
}

作者:ricklo    项目:arduino-builde   
func TestLoadSketchFromFolder(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_SKETCH_LOCATION] = "sketch_with_subfolders"

	loggerCommand := builder.SetupHumanLoggerIfMissing{}
	err := loggerCommand.Run(context)
	NoError(t, err)

	loader := builder.SketchLoader{}
	err = loader.Run(context)
	NoError(t, err)

	sketch := context[constants.CTX_SKETCH].(*types.Sketch)
	require.NotNil(t, sketch)

	require.True(t, strings.Index(sketch.MainFile.Name, "sketch_with_subfolders.ino") != -1)

	require.Equal(t, 1, len(sketch.AdditionalFiles))
	require.True(t, strings.Index(sketch.AdditionalFiles[0].Name, "other.cpp") != -1)
}


问题


面经


文章

微信
公众号

扫码关注公众号